From e7a649d0d4382567522c011b3a441459b0e9bd0c Mon Sep 17 00:00:00 2001 From: Elijah Kuntz Date: Thu, 11 Jun 2026 11:53:30 -0700 Subject: [PATCH] Add debug logging and allow responsive aspect ratio for thumbnails --- backend/handlers/onlyoffice.go | 14 ++++++++++++-- frontend/src/components/OfficeHome.tsx | 2 ++ frontend/src/components/ThumbnailImage.tsx | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/handlers/onlyoffice.go b/backend/handlers/onlyoffice.go index 67a2fad..5eeab38 100644 --- a/backend/handlers/onlyoffice.go +++ b/backend/handlers/onlyoffice.go @@ -335,16 +335,20 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error { var results []OfficeFile checksums := make(map[string]string) - rows, err := h.DB.Query("SELECT path, checksum FROM files WHERE checksum IS NOT NULL AND checksum != '' AND IFNULL(is_trashed, 0) = 0") + dbPaths := []string{} + rows, err := h.DB.Query("SELECT path, checksum FROM files WHERE checksum IS NOT NULL AND checksum != ''") if err == nil { defer rows.Close() for rows.Next() { var p, c string if rows.Scan(&p, &c) == nil { checksums[p] = c + dbPaths = append(dbPaths, p) } } } + + walkPaths := []string{} filepath.Walk(h.Config.StorageDir, func(path string, info os.FileInfo, err error) error { if err != nil { @@ -362,12 +366,16 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error { if strings.HasSuffix(strings.ToLower(info.Name()), ext) { relPath, _ := filepath.Rel(h.Config.StorageDir, path) relPathSlash := filepath.ToSlash(relPath) + + chk := checksums[relPathSlash] + walkPaths = append(walkPaths, relPathSlash) + results = append(results, OfficeFile{ Name: info.Name(), Path: relPathSlash, Size: info.Size(), ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"), - Checksum: checksums[relPathSlash], + Checksum: chk, }) } return nil @@ -380,6 +388,8 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error { return c.JSON(fiber.Map{ "files": results, "count": len(results), + "debug_db": dbPaths, + "debug_walk": walkPaths, }) } diff --git a/frontend/src/components/OfficeHome.tsx b/frontend/src/components/OfficeHome.tsx index e100293..9f583ef 100644 --- a/frontend/src/components/OfficeHome.tsx +++ b/frontend/src/components/OfficeHome.tsx @@ -92,6 +92,8 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinCha // Fetch ALL office files recursively api.listOfficeFiles(fileTypeParam) .then(data => { + console.log("ListOfficeFiles Debug DB:", data.debug_db); + console.log("ListOfficeFiles Debug Walk:", data.debug_walk); const files = (data.files || []).map((f: any) => ({ ...f, is_dir: false, diff --git a/frontend/src/components/ThumbnailImage.tsx b/frontend/src/components/ThumbnailImage.tsx index cede2e1..b2f2fe8 100644 --- a/frontend/src/components/ThumbnailImage.tsx +++ b/frontend/src/components/ThumbnailImage.tsx @@ -20,7 +20,7 @@ export default function ThumbnailImage({ checksum, fallbackIcon, downloadToken, }, [checksum]); const docStyle = docType === 'docs' - ? 'h-[85%] max-w-[85%] aspect-[1/1.4] bg-white border border-gray-300 dark:border-gray-600 shadow-md' + ? `h-[85%] max-w-[85%] ${showFallback ? 'aspect-[1/1.4]' : 'aspect-auto'} bg-white border border-gray-300 dark:border-gray-600 shadow-md` : docType === 'slides' ? 'w-[85%] max-h-[85%] aspect-[16/9] bg-white border border-gray-300 dark:border-gray-600 shadow-md' : docType === 'sheets'