Add debug logging and allow responsive aspect ratio for thumbnails
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m9s

This commit is contained in:
Elijah Kuntz 2026-06-11 11:53:30 -07:00
parent 939af551dc
commit e7a649d0d4
3 changed files with 15 additions and 3 deletions

View file

@ -335,17 +335,21 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
var results []OfficeFile var results []OfficeFile
checksums := make(map[string]string) 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 { if err == nil {
defer rows.Close() defer rows.Close()
for rows.Next() { for rows.Next() {
var p, c string var p, c string
if rows.Scan(&p, &c) == nil { if rows.Scan(&p, &c) == nil {
checksums[p] = c checksums[p] = c
dbPaths = append(dbPaths, p)
} }
} }
} }
walkPaths := []string{}
filepath.Walk(h.Config.StorageDir, func(path string, info os.FileInfo, err error) error { filepath.Walk(h.Config.StorageDir, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
return nil return nil
@ -362,12 +366,16 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
if strings.HasSuffix(strings.ToLower(info.Name()), ext) { if strings.HasSuffix(strings.ToLower(info.Name()), ext) {
relPath, _ := filepath.Rel(h.Config.StorageDir, path) relPath, _ := filepath.Rel(h.Config.StorageDir, path)
relPathSlash := filepath.ToSlash(relPath) relPathSlash := filepath.ToSlash(relPath)
chk := checksums[relPathSlash]
walkPaths = append(walkPaths, relPathSlash)
results = append(results, OfficeFile{ results = append(results, OfficeFile{
Name: info.Name(), Name: info.Name(),
Path: relPathSlash, Path: relPathSlash,
Size: info.Size(), Size: info.Size(),
ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"), ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"),
Checksum: checksums[relPathSlash], Checksum: chk,
}) })
} }
return nil return nil
@ -380,6 +388,8 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"files": results, "files": results,
"count": len(results), "count": len(results),
"debug_db": dbPaths,
"debug_walk": walkPaths,
}) })
} }

View file

@ -92,6 +92,8 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinCha
// Fetch ALL office files recursively // Fetch ALL office files recursively
api.listOfficeFiles(fileTypeParam) api.listOfficeFiles(fileTypeParam)
.then(data => { .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) => ({ const files = (data.files || []).map((f: any) => ({
...f, ...f,
is_dir: false, is_dir: false,

View file

@ -20,7 +20,7 @@ export default function ThumbnailImage({ checksum, fallbackIcon, downloadToken,
}, [checksum]); }, [checksum]);
const docStyle = docType === 'docs' 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' : docType === 'slides'
? 'w-[85%] max-h-[85%] aspect-[16/9] bg-white border border-gray-300 dark:border-gray-600 shadow-md' ? 'w-[85%] max-h-[85%] aspect-[16/9] bg-white border border-gray-300 dark:border-gray-600 shadow-md'
: docType === 'sheets' : docType === 'sheets'