Shared file bug fixes, redesigned pin system, new info button
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m15s

This commit is contained in:
Elijah 2026-05-22 18:59:26 -07:00
parent 71ba029fbc
commit 2bcfca983c
7 changed files with 511 additions and 276 deletions

View file

@ -160,6 +160,66 @@ func (h *FSHandler) getFileInfo(c *fiber.Ctx, absPath string) error {
return c.JSON(fi)
}
// GetExtendedFileInfo gets recursive size and file count for info modal
// GET /api/files/info/*
func (h *FSHandler) GetExtendedFileInfo(c *fiber.Ctx) error {
resolvedPath := c.Locals("resolvedPath").(string)
relativePath := c.Locals("relativePath").(string)
info, err := os.Stat(resolvedPath)
if err != nil {
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": "file not found"})
}
fi := FileInfo{
Name: info.Name(),
Path: filepath.ToSlash(relativePath),
IsDir: info.IsDir(),
Size: info.Size(),
MimeType: mime.TypeByExtension(filepath.Ext(info.Name())),
ModTime: info.ModTime(),
}
var isPinned int
var isTrashed int
var checksum sql.NullString
var createdAt string
err = h.DB.QueryRow(
"SELECT is_pinned, is_trashed, checksum, created_at FROM files WHERE path = ?",
filepath.ToSlash(relativePath),
).Scan(&isPinned, &isTrashed, &checksum, &createdAt)
if err == nil {
fi.IsPinned = isPinned == 1
fi.IsTrashed = isTrashed == 1
if checksum.Valid {
fi.Checksum = checksum.String
}
}
fileCount := 0
if fi.IsDir {
var totalSize int64 = 0
filepath.Walk(resolvedPath, func(p string, i os.FileInfo, err error) error {
if err != nil {
return nil
}
if !i.IsDir() {
totalSize += i.Size()
fileCount++
}
return nil
})
fi.Size = totalSize
}
return c.JSON(fiber.Map{
"info": fi,
"file_count": fileCount,
"created_at": createdAt,
})
}
// CreateFolder creates a new directory.
// POST /api/files/mkdir
func (h *FSHandler) CreateFolder(c *fiber.Ctx) error {