Fox files not showing thumbnails in all documents section
All checks were successful
Automated Container Build / build-and-push (push) Successful in 58s

This commit is contained in:
Elijah 2026-06-15 18:26:51 -07:00
parent c9e078586f
commit 83e73b4d52
3 changed files with 44 additions and 1 deletions

View file

@ -362,12 +362,30 @@ 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]
if chk == "" {
// Fallback: the path in the database might have a different prefix format
// (e.g. "/test.docx", "./test.docx") or different casing.
cleanRel := filepath.ToSlash(filepath.Clean(relPathSlash))
cleanRel = strings.TrimPrefix(cleanRel, "/")
for k, v := range checksums {
cleanK := filepath.ToSlash(filepath.Clean(k))
cleanK = strings.TrimPrefix(cleanK, "/")
if strings.EqualFold(cleanK, cleanRel) {
chk = v
break
}
}
}
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

25
backend/scratch.go Normal file
View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"path/filepath"
"strings"
)
func main() {
storageDir := `C:\Users\Elijah\Desktop\Drive\data`
path1 := `C:\Users\Elijah\Desktop\Drive\data\test.docx`
path2 := `C:\Users\Elijah\Desktop\Drive\data\folder\test.docx`
relPath1, _ := filepath.Rel(storageDir, path1)
relPathSlash1 := filepath.ToSlash(relPath1)
relPath2, _ := filepath.Rel(storageDir, path2)
relPathSlash2 := filepath.ToSlash(relPath2)
fmt.Printf("Root file: %q -> %q\n", relPath1, relPathSlash1)
fmt.Printf("Sub file: %q -> %q\n", relPath2, relPathSlash2)
fmt.Printf("Clean . : %q\n", filepath.Clean("."))
fmt.Printf("Join . and file: %q\n", filepath.Join(".", "test.docx"))
}

BIN
test_rel.go Normal file

Binary file not shown.