From ffa2954cd920eb047da42aa8a3d052159440f5e0 Mon Sep 17 00:00:00 2001 From: Elijah Date: Mon, 25 May 2026 16:14:52 -0700 Subject: [PATCH] Fix: sidebar navigation from settings, missing thumbnails in all documents, and hiding upload buttons in office modes --- backend/handlers/onlyoffice.go | 31 ++++++++++++++++++------ frontend/src/components/FileExplorer.tsx | 14 +++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/backend/handlers/onlyoffice.go b/backend/handlers/onlyoffice.go index ee2802b..e804a2d 100644 --- a/backend/handlers/onlyoffice.go +++ b/backend/handlers/onlyoffice.go @@ -302,14 +302,27 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error { } type OfficeFile struct { - Name string `json:"name"` - Path string `json:"path"` - Size int64 `json:"size"` - ModTime string `json:"mod_time"` + Name string `json:"name"` + Path string `json:"path"` + Size int64 `json:"size"` + ModTime string `json:"mod_time"` + Checksum string `json:"checksum,omitempty"` } var results []OfficeFile + checksums := make(map[string]string) + rows, err := h.DB.Query("SELECT path, checksum FROM files WHERE checksum != '' AND is_trashed = 0") + if err == nil { + defer rows.Close() + for rows.Next() { + var p, c string + if rows.Scan(&p, &c) == nil { + checksums[p] = c + } + } + } + filepath.Walk(h.Config.StorageDir, func(path string, info os.FileInfo, err error) error { if err != nil { return nil @@ -325,11 +338,13 @@ 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) results = append(results, OfficeFile{ - Name: info.Name(), - Path: filepath.ToSlash(relPath), - Size: info.Size(), - ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"), + Name: info.Name(), + Path: relPathSlash, + Size: info.Size(), + ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"), + Checksum: checksums[relPathSlash], }) } return nil diff --git a/frontend/src/components/FileExplorer.tsx b/frontend/src/components/FileExplorer.tsx index b48d33e..0ad31fe 100644 --- a/frontend/src/components/FileExplorer.tsx +++ b/frontend/src/components/FileExplorer.tsx @@ -1403,7 +1403,7 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { >
- {activeSection === 'files' && ( + {activeSection === 'files' && appMode === 'drive' && (
)} - {activeSection === 'files' && ( + {activeSection === 'files' && appMode === 'drive' && ( <>