fix: preserve .folder-icons.json across thumbnail cache sync cycles
@@ -175,6 +175,7 @@ async function pruneThumbTree (dirPath, keepFiles)
175
175
}
176
176
177
177
if (full === MANIFEST_PATH || full === MANIFEST_PATH + '.tmp') continue;
178
if (full === FOLDER_ICONS_PATH || full === FOLDER_ICONS_PATH + '.tmp') continue;
178
179
if (!keepFiles.has(path.resolve(full)))
179
180
{
180
181
await removeFileIfExists(full);
@@ -175,6 +175,7 @@ async function pruneThumbTree (dirPath, keepFiles)175
}175
}176
176
177
if (full === MANIFEST_PATH || full === MANIFEST_PATH + '.tmp') continue;177
if (full === MANIFEST_PATH || full === MANIFEST_PATH + '.tmp') continue;178
if (full === FOLDER_ICONS_PATH || full === FOLDER_ICONS_PATH + '.tmp') continue;178
if (!keepFiles.has(path.resolve(full)))179
if (!keepFiles.has(path.resolve(full)))179
{180
{180
await removeFileIfExists(full);181
await removeFileIfExists(full);@@ -96,4 +96,25 @@ describe('thumbnail cache worker', () =>
96
96
97
97
expect(fs.existsSync(thumbPath)).toBe(false);
98
98
});
99
100
test('preserves folder-icons.json across sync cycles', async () =>
101
{
102
const mod = loadModule();
103
104
// Run one sync to create the thumbs dir.
105
await mod.syncThumbnailCacheOnce();
106
107
// Write a folder icon assignment directly.
108
await mod.setFolderIconAssignment(sourceRoot, path.join(sourceRoot, 'cover.jpg'));
109
110
const iconsPath = path.join(thumbsDir, '.folder-icons.json');
111
expect(fs.existsSync(iconsPath)).toBe(true);
112
113
// Run sync again — the file must survive pruning.
114
await mod.syncThumbnailCacheOnce();
115
116
expect(fs.existsSync(iconsPath)).toBe(true);
117
const stored = JSON.parse(fs.readFileSync(iconsPath, 'utf8'));
118
expect(stored[path.resolve(sourceRoot)]).toBe(path.join(sourceRoot, 'cover.jpg'));
119
});
99
120
});
@@ -96,4 +96,25 @@ describe('thumbnail cache worker', () =>96
96
97
expect(fs.existsSync(thumbPath)).toBe(false);97
expect(fs.existsSync(thumbPath)).toBe(false);98
});98
});99
100
test('preserves folder-icons.json across sync cycles', async () =>101
{102
const mod = loadModule();103
104
// Run one sync to create the thumbs dir.105
await mod.syncThumbnailCacheOnce();106
107
// Write a folder icon assignment directly.108
await mod.setFolderIconAssignment(sourceRoot, path.join(sourceRoot, 'cover.jpg'));109
110
const iconsPath = path.join(thumbsDir, '.folder-icons.json');111
expect(fs.existsSync(iconsPath)).toBe(true);112
113
// Run sync again — the file must survive pruning.114
await mod.syncThumbnailCacheOnce();115
116
expect(fs.existsSync(iconsPath)).toBe(true);117
const stored = JSON.parse(fs.readFileSync(iconsPath, 'utf8'));118
expect(stored[path.resolve(sourceRoot)]).toBe(path.join(sourceRoot, 'cover.jpg'));119
});99
});120
});