fix(library): resolve root folder rename, open in explorer, open at location centering, UPDATE rescan bug, and optimize scan RAM memory usage

This commit is contained in:
2026-10-07 19:16:03 +07:00
parent af76b46c3e
commit 9bfb39be91
5 changed files with 82 additions and 21 deletions
+14 -5
View File
@@ -146,7 +146,7 @@ export function canBrowseFolders(): boolean {
return typeof window !== 'undefined' && 'showDirectoryPicker' in window;
}
const THUMB_CACHE_MAX = 5000;
const THUMB_CACHE_MAX = 800;
const thumbCache = new Map<string, Blob>();
export function cacheThumb(id: string, blob: Blob): void {
@@ -729,7 +729,13 @@ export async function scanFolder(
// frames it does not re-read are skipped on their size and their time.
const bounded = from !== '';
const saved = bounded ? null : await loadWalk(folder.name);
const tree: Walk = { root: folder.handle, pending: [], walked: new Set(saved?.walked ?? []) };
const treeWalked = new Set(saved?.walked ?? []);
if (from) {
for (const p of [...treeWalked]) {
if (p === from || p.startsWith(from)) treeWalked.delete(p);
}
}
const tree: Walk = { root: folder.handle, pending: [], walked: treeWalked };
// A queue comes back as paths, so the folders are asked for again; a reading
// with nothing written down starts at the folder it was pointed at — the
// picked one, or the one the reader right-clicked inside it.
@@ -738,6 +744,10 @@ export async function scanFolder(
const dir = await openAt(folder.handle, rel);
if (dir) tree.pending.push({ dir, rel });
}
if (from && !tree.pending.some((p) => p.rel === from)) {
const dir = await openAt(folder.handle, from);
if (dir) tree.pending.unshift({ dir, rel: from });
}
} else {
const dir = from ? await openAt(folder.handle, from) : folder.handle;
if (dir) tree.pending.push({ dir, rel: from });
@@ -991,9 +1001,8 @@ export async function scanFolder(
progress.done++;
count(rel);
}
// A RAW takes the one open there is before its lane does anything, so a
// folder of them is read a frame at a time whatever the lanes say.
const read = isRawName(handle.name) ? oneRawAtATime(() => readOne(handle, rel)) : readOne(handle, rel);
// Queue image decoding one at a time so memory usage stays low and UI stays smooth
const read = oneRawAtATime(() => readOne(handle, rel));
const lane = read
.catch(() => undefined)
.finally(() => lanes.delete(lane));