BlueGit

timfa filemanager

Allow folder icons to use any cached file thumbnail

timfa Tim Falken · pushed by timfa

Authored 2026-05-15 · 6 months ago

Hash
d65464e6e98316d6464480a356f564f8b636ce0a
Parent
45ac321e
5 files changed +39 −19
.github/technical-reference.md +3 −3
@@ -12,7 +12,7 @@
12 12 - getCachedThumbnailInfo(sourceFile) - Returns cached thumbnail path/content-type when present; null when not ready.
13 13 - getThumbPathForSourceFile(sourceFile) - Maps an absolute source file path to its mirrored cache thumbnail path.
14 14 - getThumbRelPathForSourceFile(sourceFile) - Returns public-relative thumbnail path used in manifest entries.
15 - getImagesWithThumbnailsInDir(dirPath) - Returns [{filePath, thumbRelPath}] for all images inside dirPath (recursive) that have a cached thumbnail; sorted by filePath.
15 - getFilesWithThumbnailsInDir(dirPath) - Returns [{filePath, thumbRelPath}] for all files inside dirPath (recursive) that have a cached thumbnail; sorted by filePath.
16 16 - getFolderIconSourceFile(folderPath) - Returns the source image path for a folder's icon: explicit assignment first, then auto-first cached image, null if none.
17 17 - setFolderIconAssignment(folderPath, imagePath) - Saves an explicit folder icon assignment to .folder-icons.json; pass null to clear (auto-detect used instead).
18 18
@@ -59,7 +59,7 @@
59 59 - GET /api/files/duplicates - Returns accessible files that share the selected file's sha256 hash.
60 60 - GET /api/files/space - Returns used/free disk space and, for personal folders, user-limit fields (userLimitBytes/userFreeBytes).
61 61 - GET /api/files/thumbnail - Serves cache-only thumbnail images for authorized files; returns 404 while cache is not ready.
62 - GET /api/files/folder-images - Returns images inside a directory (recursive) that already have a cached thumbnail; only thumbnailed images are included per user requirement.
62 - GET /api/files/folder-images - Returns files inside a directory (recursive) that already have a cached thumbnail (including video thumbnails when cached).
63 63 - GET /api/files/folder-icon - Returns the current icon source file for a folder ({icon:{filePath}} or {icon:null}); explicit assignment takes priority over auto-first.
64 64 - POST /api/files/folder-icon - Sets or clears a folder's explicit icon assignment; imagePath must have a cached thumbnail; write access required.
65 65 - GET /api/files/download-zip?dir=<absolute-path> - Authenticated. Streams the directory as a zip archive; caches the zip for up to 1 day in zip-cache/.
@@ -148,7 +148,7 @@
148 148 - observeFolderIcon(iconEl) - Registers a folder icon element with IntersectionObserver for lazy loading.
149 149 - loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
150 150 - applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
151 - openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail images from the folder; allows selection, clearing, and cancellation.
151 - openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
152 152 - refreshAfterIconChange(item) - Resets and reloads the folder icon in both the grid tile and sidebar after set/clear operations.
153 153 - disconnectFolderIconObserver() - Disconnects and clears the folder icon IntersectionObserver on grid rebuild.
154 154 - getThumbnailKind(name) - Classifies files into image/text/badge thumbnail strategies.
@@ -12,7 +12,7 @@
12- getCachedThumbnailInfo(sourceFile) - Returns cached thumbnail path/content-type when present; null when not ready.
12- getCachedThumbnailInfo(sourceFile) - Returns cached thumbnail path/content-type when present; null when not ready.
13- getThumbPathForSourceFile(sourceFile) - Maps an absolute source file path to its mirrored cache thumbnail path.
13- getThumbPathForSourceFile(sourceFile) - Maps an absolute source file path to its mirrored cache thumbnail path.
14- getThumbRelPathForSourceFile(sourceFile) - Returns public-relative thumbnail path used in manifest entries.
14- getThumbRelPathForSourceFile(sourceFile) - Returns public-relative thumbnail path used in manifest entries.
15- getImagesWithThumbnailsInDir(dirPath) - Returns [{filePath, thumbRelPath}] for all images inside dirPath (recursive) that have a cached thumbnail; sorted by filePath.
15- getFilesWithThumbnailsInDir(dirPath) - Returns [{filePath, thumbRelPath}] for all files inside dirPath (recursive) that have a cached thumbnail; sorted by filePath.
16- getFolderIconSourceFile(folderPath) - Returns the source image path for a folder's icon: explicit assignment first, then auto-first cached image, null if none.
16- getFolderIconSourceFile(folderPath) - Returns the source image path for a folder's icon: explicit assignment first, then auto-first cached image, null if none.
17- setFolderIconAssignment(folderPath, imagePath) - Saves an explicit folder icon assignment to .folder-icons.json; pass null to clear (auto-detect used instead).
17- setFolderIconAssignment(folderPath, imagePath) - Saves an explicit folder icon assignment to .folder-icons.json; pass null to clear (auto-detect used instead).
18
18
@@ -59,7 +59,7 @@
59- GET /api/files/duplicates - Returns accessible files that share the selected file's sha256 hash.
59- GET /api/files/duplicates - Returns accessible files that share the selected file's sha256 hash.
60- GET /api/files/space - Returns used/free disk space and, for personal folders, user-limit fields (userLimitBytes/userFreeBytes).
60- GET /api/files/space - Returns used/free disk space and, for personal folders, user-limit fields (userLimitBytes/userFreeBytes).
61- GET /api/files/thumbnail - Serves cache-only thumbnail images for authorized files; returns 404 while cache is not ready.
61- GET /api/files/thumbnail - Serves cache-only thumbnail images for authorized files; returns 404 while cache is not ready.
62- GET /api/files/folder-images - Returns images inside a directory (recursive) that already have a cached thumbnail; only thumbnailed images are included per user requirement.
62- GET /api/files/folder-images - Returns files inside a directory (recursive) that already have a cached thumbnail (including video thumbnails when cached).
63- GET /api/files/folder-icon - Returns the current icon source file for a folder ({icon:{filePath}} or {icon:null}); explicit assignment takes priority over auto-first.
63- GET /api/files/folder-icon - Returns the current icon source file for a folder ({icon:{filePath}} or {icon:null}); explicit assignment takes priority over auto-first.
64- POST /api/files/folder-icon - Sets or clears a folder's explicit icon assignment; imagePath must have a cached thumbnail; write access required.
64- POST /api/files/folder-icon - Sets or clears a folder's explicit icon assignment; imagePath must have a cached thumbnail; write access required.
65- GET /api/files/download-zip?dir=<absolute-path> - Authenticated. Streams the directory as a zip archive; caches the zip for up to 1 day in zip-cache/.
65- GET /api/files/download-zip?dir=<absolute-path> - Authenticated. Streams the directory as a zip archive; caches the zip for up to 1 day in zip-cache/.
@@ -148,7 +148,7 @@
148- observeFolderIcon(iconEl) - Registers a folder icon element with IntersectionObserver for lazy loading.
148- observeFolderIcon(iconEl) - Registers a folder icon element with IntersectionObserver for lazy loading.
149- loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
149- loadOneFolderIcon(iconEl) - Fetches /api/files/folder-icon then the thumbnail blob and overlays it inside the folder SVG; no-op if no icon available.
150- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
150- applyFolderThumbnail(iconEl, srcUrl) - Injects an SVG <image> element clipped to the folder outline path into the folder's icon SVG.
151- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail images from the folder; allows selection, clearing, and cancellation.
151- openFolderIconPicker(item) - Opens the folder icon picker modal; shows cached-thumbnail files from the folder (including video thumbnails); allows selection, clearing, and cancellation.
152- refreshAfterIconChange(item) - Resets and reloads the folder icon in both the grid tile and sidebar after set/clear operations.
152- refreshAfterIconChange(item) - Resets and reloads the folder icon in both the grid tile and sidebar after set/clear operations.
153- disconnectFolderIconObserver() - Disconnects and clears the folder icon IntersectionObserver on grid rebuild.
153- disconnectFolderIconObserver() - Disconnects and clears the folder icon IntersectionObserver on grid rebuild.
154- getThumbnailKind(name) - Classifies files into image/text/badge thumbnail strategies.
154- getThumbnailKind(name) - Classifies files into image/text/badge thumbnail strategies.
public/app.js +3 −3
@@ -2460,7 +2460,7 @@ async function openFolderIconPicker (item)
2460 2460 return;
2461 2461 }
2462 2462
2463 // Fetch the list of available images (only those with cached thumbnails).
2463 // Fetch the list of available files (only those with cached thumbnails).
2464 2464 const data = await api('GET', `/files/folder-images?dir=${encodeURIComponent(item.path)}`).catch(() => null);
2465 2465 const images = data ? data.images : [];
2466 2466
@@ -2490,10 +2490,10 @@ async function openFolderIconPicker (item)
2490 2490
2491 2491 if (!images.length)
2492 2492 {
2493 subtitle.textContent = 'No images with cached thumbnails were found inside this folder.';
2493 subtitle.textContent = 'No files with cached thumbnails were found inside this folder.';
2494 2494 } else
2495 2495 {
2496 subtitle.textContent = 'Select an image to use as the folder icon.';
2496 subtitle.textContent = 'Select a file thumbnail to use as the folder icon.';
2497 2497
2498 2498 for (const { filePath } of images)
2499 2499 {
@@ -2460,7 +2460,7 @@ async function openFolderIconPicker (item)
2460 return;
2460 return;
2461 }
2461 }
2462
2462
2463 // Fetch the list of available images (only those with cached thumbnails).
2463 // Fetch the list of available files (only those with cached thumbnails).
2464 const data = await api('GET', `/files/folder-images?dir=${encodeURIComponent(item.path)}`).catch(() => null);
2464 const data = await api('GET', `/files/folder-images?dir=${encodeURIComponent(item.path)}`).catch(() => null);
2465 const images = data ? data.images : [];
2465 const images = data ? data.images : [];
2466
2466
@@ -2490,10 +2490,10 @@ async function openFolderIconPicker (item)
2490
2490
2491 if (!images.length)
2491 if (!images.length)
2492 {
2492 {
2493 subtitle.textContent = 'No images with cached thumbnails were found inside this folder.';
2493 subtitle.textContent = 'No files with cached thumbnails were found inside this folder.';
2494 } else
2494 } else
2495 {
2495 {
2496 subtitle.textContent = 'Select an image to use as the folder icon.';
2496 subtitle.textContent = 'Select a file thumbnail to use as the folder icon.';
2497
2497
2498 for (const { filePath } of images)
2498 for (const { filePath } of images)
2499 {
2499 {
server/routes/files.js +5 −5
@@ -10,7 +10,7 @@ const router = express.Router();
10 10 const { getDb } = require('../db');
11 11 const { loadConfig, saveConfig, getEffectivePaths, getAllowedRoot } = require('../config');
12 12 const { requireAuth } = require('../auth');
13 const { getCachedThumbnailInfo, getImagesWithThumbnailsInDir, getFolderIconSourceFile, setFolderIconAssignment } = require('../thumbnail-cache');
13 const { getCachedThumbnailInfo, getFilesWithThumbnailsInDir, getFolderIconSourceFile, setFolderIconAssignment } = require('../thumbnail-cache');
14 14 const { buildZip } = require('./share');
15 15 const { createVideoStreamSession, sendVideoStreamAsset, releaseVideoStreamSession } = require('../video-stream');
16 16
@@ -1499,8 +1499,8 @@ router.post('/delete', requireAuth, (req, res) =>
1499 1499
1500 1500 // ---------------------------------------------------------------------------
1501 1501 // GET /api/files/folder-images?dir=<absolute-path>
1502 // Returns images inside dir (recursive) that already have a cached thumbnail.
1503 // Only images with a ready thumbnail are included (user constraint).
1502 // Returns files inside dir (recursive) that already have a cached thumbnail.
1503 // Only files with a ready cached thumbnail are included.
1504 1504 // ---------------------------------------------------------------------------
1505 1505 router.get('/folder-images', requireAuth, async (req, res) =>
1506 1506 {
@@ -1519,9 +1519,9 @@ router.get('/folder-images', requireAuth, async (req, res) =>
1519 1519 return res.status(404).json({ error: 'Directory not found.' });
1520 1520 }
1521 1521
1522 const images = await getImagesWithThumbnailsInDir(dir);
1522 const files = await getFilesWithThumbnailsInDir(dir);
1523 1523 // Filter out any that escaped to a different accessible root (safety check).
1524 const filtered = images.filter(({ filePath }) => isAccessiblePath(filePath, roots, req.user, config));
1524 const filtered = files.filter(({ filePath }) => isAccessiblePath(filePath, roots, req.user, config));
1525 1525
1526 1526 res.json({ images: filtered.map(({ filePath }) => ({ filePath })) });
1527 1527 });
@@ -10,7 +10,7 @@ const router = express.Router();
10const { getDb } = require('../db');
10const { getDb } = require('../db');
11const { loadConfig, saveConfig, getEffectivePaths, getAllowedRoot } = require('../config');
11const { loadConfig, saveConfig, getEffectivePaths, getAllowedRoot } = require('../config');
12const { requireAuth } = require('../auth');
12const { requireAuth } = require('../auth');
13const { getCachedThumbnailInfo, getImagesWithThumbnailsInDir, getFolderIconSourceFile, setFolderIconAssignment } = require('../thumbnail-cache');
13const { getCachedThumbnailInfo, getFilesWithThumbnailsInDir, getFolderIconSourceFile, setFolderIconAssignment } = require('../thumbnail-cache');
14const { buildZip } = require('./share');
14const { buildZip } = require('./share');
15const { createVideoStreamSession, sendVideoStreamAsset, releaseVideoStreamSession } = require('../video-stream');
15const { createVideoStreamSession, sendVideoStreamAsset, releaseVideoStreamSession } = require('../video-stream');
16
16
@@ -1499,8 +1499,8 @@ router.post('/delete', requireAuth, (req, res) =>
1499
1499
1500// ---------------------------------------------------------------------------
1500// ---------------------------------------------------------------------------
1501// GET /api/files/folder-images?dir=<absolute-path>
1501// GET /api/files/folder-images?dir=<absolute-path>
1502// Returns images inside dir (recursive) that already have a cached thumbnail.
1502// Returns files inside dir (recursive) that already have a cached thumbnail.
1503// Only images with a ready thumbnail are included (user constraint).
1503// Only files with a ready cached thumbnail are included.
1504// ---------------------------------------------------------------------------
1504// ---------------------------------------------------------------------------
1505router.get('/folder-images', requireAuth, async (req, res) =>
1505router.get('/folder-images', requireAuth, async (req, res) =>
1506{
1506{
@@ -1519,9 +1519,9 @@ router.get('/folder-images', requireAuth, async (req, res) =>
1519 return res.status(404).json({ error: 'Directory not found.' });
1519 return res.status(404).json({ error: 'Directory not found.' });
1520 }
1520 }
1521
1521
1522 const images = await getImagesWithThumbnailsInDir(dir);
1522 const files = await getFilesWithThumbnailsInDir(dir);
1523 // Filter out any that escaped to a different accessible root (safety check).
1523 // Filter out any that escaped to a different accessible root (safety check).
1524 const filtered = images.filter(({ filePath }) => isAccessiblePath(filePath, roots, req.user, config));
1524 const filtered = files.filter(({ filePath }) => isAccessiblePath(filePath, roots, req.user, config));
1525
1525
1526 res.json({ images: filtered.map(({ filePath }) => ({ filePath })) });
1526 res.json({ images: filtered.map(({ filePath }) => ({ filePath })) });
1527});
1527});
server/thumbnail-cache.js +13 −6
@@ -599,11 +599,11 @@ async function writeFolderIcons (obj)
599 599 }
600 600
601 601 /**
602 * Returns all images inside `dirPath` (recursive) that have a cached thumbnail,
602 * Returns all files inside `dirPath` (recursive) that have a cached thumbnail,
603 603 * sorted lexicographically by absolute file path.
604 604 * Each element: { filePath: string, thumbRelPath: string }
605 605 */
606 async function getImagesWithThumbnailsInDir (dirPath)
606 async function getFilesWithThumbnailsInDir (dirPath)
607 607 {
608 608 const manifest = await readManifest();
609 609 const resolved = path.resolve(dirPath);
@@ -627,10 +627,16 @@ async function getImagesWithThumbnailsInDir (dirPath)
627 627 return results;
628 628 }
629 629
630 // Backward-compatible alias used by existing imports/tests.
631 async function getImagesWithThumbnailsInDir (dirPath)
632 {
633 return getFilesWithThumbnailsInDir(dirPath);
634 }
635
630 636 /**
631 * Returns the source image file path used as the icon for `folderPath`.
637 * Returns the source file path used as the icon for `folderPath`.
632 638 * Looks up the explicit assignment first; falls back to the first cached image found.
633 * Returns null when no images with cached thumbnails exist inside the folder.
639 * Returns null when no files with cached thumbnails exist inside the folder.
634 640 */
635 641 async function getFolderIconSourceFile (folderPath)
636 642 {
@@ -647,8 +653,8 @@ async function getFolderIconSourceFile (folderPath)
647 653 }
648 654
649 655 // Auto: first cached image inside the folder.
650 const images = await getImagesWithThumbnailsInDir(folderPath);
651 return images.length ? images[0].filePath : null;
656 const files = await getFilesWithThumbnailsInDir(folderPath);
657 return files.length ? files[0].filePath : null;
652 658 }
653 659
654 660 /**
@@ -675,6 +681,7 @@ module.exports = {
675 681 getCachedThumbnailInfo,
676 682 getThumbPathForSourceFile,
677 683 getThumbRelPathForSourceFile,
684 getFilesWithThumbnailsInDir,
678 685 getImagesWithThumbnailsInDir,
679 686 getFolderIconSourceFile,
680 687 setFolderIconAssignment,
@@ -599,11 +599,11 @@ async function writeFolderIcons (obj)
599}
599}
600
600
601/**
601/**
602 * Returns all images inside `dirPath` (recursive) that have a cached thumbnail,
602 * Returns all files inside `dirPath` (recursive) that have a cached thumbnail,
603 * sorted lexicographically by absolute file path.
603 * sorted lexicographically by absolute file path.
604 * Each element: { filePath: string, thumbRelPath: string }
604 * Each element: { filePath: string, thumbRelPath: string }
605 */
605 */
606async function getImagesWithThumbnailsInDir (dirPath)
606async function getFilesWithThumbnailsInDir (dirPath)
607{
607{
608 const manifest = await readManifest();
608 const manifest = await readManifest();
609 const resolved = path.resolve(dirPath);
609 const resolved = path.resolve(dirPath);
@@ -627,10 +627,16 @@ async function getImagesWithThumbnailsInDir (dirPath)
627 return results;
627 return results;
628}
628}
629
629
630// Backward-compatible alias used by existing imports/tests.
631async function getImagesWithThumbnailsInDir (dirPath)
632{
633 return getFilesWithThumbnailsInDir(dirPath);
634}
635
630/**
636/**
631 * Returns the source image file path used as the icon for `folderPath`.
637 * Returns the source file path used as the icon for `folderPath`.
632 * Looks up the explicit assignment first; falls back to the first cached image found.
638 * Looks up the explicit assignment first; falls back to the first cached image found.
633 * Returns null when no images with cached thumbnails exist inside the folder.
639 * Returns null when no files with cached thumbnails exist inside the folder.
634 */
640 */
635async function getFolderIconSourceFile (folderPath)
641async function getFolderIconSourceFile (folderPath)
636{
642{
@@ -647,8 +653,8 @@ async function getFolderIconSourceFile (folderPath)
647 }
653 }
648
654
649 // Auto: first cached image inside the folder.
655 // Auto: first cached image inside the folder.
650 const images = await getImagesWithThumbnailsInDir(folderPath);
656 const files = await getFilesWithThumbnailsInDir(folderPath);
651 return images.length ? images[0].filePath : null;
657 return files.length ? files[0].filePath : null;
652}
658}
653
659
654/**
660/**
@@ -675,6 +681,7 @@ module.exports = {
675 getCachedThumbnailInfo,
681 getCachedThumbnailInfo,
676 getThumbPathForSourceFile,
682 getThumbPathForSourceFile,
677 getThumbRelPathForSourceFile,
683 getThumbRelPathForSourceFile,
684 getFilesWithThumbnailsInDir,
678 getImagesWithThumbnailsInDir,
685 getImagesWithThumbnailsInDir,
679 getFolderIconSourceFile,
686 getFolderIconSourceFile,
680 setFolderIconAssignment,
687 setFolderIconAssignment,
tests/files.routes.test.js +15 −2
@@ -81,7 +81,7 @@ jest.mock('../server/thumbnail-cache', () => ({
81 81 if (!mockThumbPath) return null;
82 82 return { thumbPath: mockThumbPath, contentType: 'image/webp' };
83 83 },
84 getImagesWithThumbnailsInDir: async () => mockFolderImages.slice(),
84 getFilesWithThumbnailsInDir: async () => mockFolderImages.slice(),
85 85 getFolderIconSourceFile: async () => mockFolderIconFile,
86 86 setFolderIconAssignment: async (folderPath, imagePath) =>
87 87 {
@@ -593,7 +593,7 @@ describe('GET /api/files/root-access', () =>
593 593
594 594 describe('folder icon endpoints', () =>
595 595 {
596 test('GET /api/files/folder-images returns images that have cached thumbnails', async () =>
596 test('GET /api/files/folder-images returns files that have cached thumbnails', async () =>
597 597 {
598 598 const subDir = path.join(rootDir, 'photos');
599 599 fs.mkdirSync(subDir);
@@ -608,6 +608,19 @@ describe('folder icon endpoints', () =>
608 608 expect(body.images[0].filePath).toBe(imgPath);
609 609 });
610 610
611 test('GET /api/files/folder-images includes video files with cached thumbnails', async () =>
612 {
613 const videoPath = path.join(rootDir, 'photos', 'clip.mp4');
614 fs.mkdirSync(path.dirname(videoPath), { recursive: true });
615 fs.writeFileSync(videoPath, 'video');
616
617 mockFolderImages = [{ filePath: videoPath, thumbRelPath: 'thumbs/clip.mp4.webp' }];
618
619 const { status, body } = await req('GET', `/api/files/folder-images?dir=${encodeURIComponent(rootDir)}`);
620 expect(status).toBe(200);
621 expect(body.images).toEqual([{ filePath: videoPath }]);
622 });
623
611 624 test('GET /api/files/folder-images returns empty list when no thumbnails available', async () =>
612 625 {
613 626 mockFolderImages = [];
@@ -81,7 +81,7 @@ jest.mock('../server/thumbnail-cache', () => ({
81 if (!mockThumbPath) return null;
81 if (!mockThumbPath) return null;
82 return { thumbPath: mockThumbPath, contentType: 'image/webp' };
82 return { thumbPath: mockThumbPath, contentType: 'image/webp' };
83 },
83 },
84 getImagesWithThumbnailsInDir: async () => mockFolderImages.slice(),
84 getFilesWithThumbnailsInDir: async () => mockFolderImages.slice(),
85 getFolderIconSourceFile: async () => mockFolderIconFile,
85 getFolderIconSourceFile: async () => mockFolderIconFile,
86 setFolderIconAssignment: async (folderPath, imagePath) =>
86 setFolderIconAssignment: async (folderPath, imagePath) =>
87 {
87 {
@@ -593,7 +593,7 @@ describe('GET /api/files/root-access', () =>
593
593
594describe('folder icon endpoints', () =>
594describe('folder icon endpoints', () =>
595{
595{
596 test('GET /api/files/folder-images returns images that have cached thumbnails', async () =>
596 test('GET /api/files/folder-images returns files that have cached thumbnails', async () =>
597 {
597 {
598 const subDir = path.join(rootDir, 'photos');
598 const subDir = path.join(rootDir, 'photos');
599 fs.mkdirSync(subDir);
599 fs.mkdirSync(subDir);
@@ -608,6 +608,19 @@ describe('folder icon endpoints', () =>
608 expect(body.images[0].filePath).toBe(imgPath);
608 expect(body.images[0].filePath).toBe(imgPath);
609 });
609 });
610
610
611 test('GET /api/files/folder-images includes video files with cached thumbnails', async () =>
612 {
613 const videoPath = path.join(rootDir, 'photos', 'clip.mp4');
614 fs.mkdirSync(path.dirname(videoPath), { recursive: true });
615 fs.writeFileSync(videoPath, 'video');
616
617 mockFolderImages = [{ filePath: videoPath, thumbRelPath: 'thumbs/clip.mp4.webp' }];
618
619 const { status, body } = await req('GET', `/api/files/folder-images?dir=${encodeURIComponent(rootDir)}`);
620 expect(status).toBe(200);
621 expect(body.images).toEqual([{ filePath: videoPath }]);
622 });
623
611 test('GET /api/files/folder-images returns empty list when no thumbnails available', async () =>
624 test('GET /api/files/folder-images returns empty list when no thumbnails available', async () =>
612 {
625 {
613 mockFolderImages = [];
626 mockFolderImages = [];