From ad6f2ae6f6aa14926ef63a7fe124093dcceb024b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 6 May 2026 08:09:30 +0300 Subject: fix(scanner, browse): fallback to original image when thumbnail generation fails for cover.jpg When scanning image files (e.g. cover.jpg in audiobook folders), thumbnailForImage can fail or produce a missing .thumbnails/cover.jpg. This caused broken thumbnails in the grid. - scanner.go buildThumbnailPath: after generating an image thumbnail, verify the output file exists via fs.Stat. If it does not exist, fall back to using the original image path as the thumbnail_path. - browse.go GetThumbnail: if os.Stat(ThumbnailPath) fails and the media type is image, fall back to serving the original AbsPath. All tests pass. --- internal/scanner/scanner.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'internal/scanner') diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 30b20d1..34e0ca5 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -202,7 +202,16 @@ func (s *FSScanner) buildThumbnailPath(ctx context.Context, path, setPath string if ext == ".svg" { return path, nil } - return s.thumbnailForImage(ctx, path, setPath) + thumbPath, err := s.thumbnailForImage(ctx, path, setPath) + if err != nil { + return "", err + } + if thumbPath != "" { + if _, statErr := s.fs.Stat(thumbPath); statErr == nil { + return thumbPath, nil + } + } + return path, nil } return "", nil } -- cgit v1.2.3