fix: realtime folder photo counts during scan discovery and decode
This commit is contained in:
@@ -809,6 +809,17 @@ export async function scanFolder(
|
||||
}
|
||||
};
|
||||
for (const id of known.keys()) count(id.startsWith(`${normRoot}/`) ? id.slice(normRoot.length + 1) : id);
|
||||
const knownPaths = new Set(
|
||||
[...known.keys()].map((id) => (id.startsWith(`${normRoot}/`) ? id.slice(normRoot.length + 1) : id))
|
||||
);
|
||||
const countedDiscovered = new Set<string>();
|
||||
const countDiscovered = (rel: string) => {
|
||||
const relClean = rel.replace(/\\/g, '/');
|
||||
if (knownPaths.has(relClean) || countedDiscovered.has(relClean)) return;
|
||||
countedDiscovered.add(relClean);
|
||||
count(relClean);
|
||||
};
|
||||
for (const e of entries) countDiscovered(e.rel);
|
||||
// The frames the catalogue already holds of the folder being read, which is
|
||||
// what the reading is measured against: a roll of a hundred thousand that has
|
||||
// been read once before is a reading of a hundred thousand frames even while
|
||||
@@ -1036,10 +1047,20 @@ export async function scanFolder(
|
||||
// through. A jump would take it out of the subtree it was kept to, and
|
||||
// the reading it left behind is the reading that folder wanted.
|
||||
const asked = bounded ? () => null : (jump ?? (() => null));
|
||||
walked = await walkPass(tree, entries, names, isSupportedPhoto, asked, (dirRel) => {
|
||||
progress.at = normPath(dirRel);
|
||||
publish(true);
|
||||
});
|
||||
walked = await walkPass(
|
||||
tree,
|
||||
entries,
|
||||
names,
|
||||
isSupportedPhoto,
|
||||
asked,
|
||||
(dirRel) => {
|
||||
progress.at = normPath(dirRel);
|
||||
publish(true);
|
||||
},
|
||||
(file) => {
|
||||
countDiscovered(file.rel);
|
||||
}
|
||||
);
|
||||
// The names come in before the frames they hold: the column grows one pass
|
||||
// ahead of the strip, which is the whole point of reading layer by layer.
|
||||
for (const rel of names) {
|
||||
|
||||
@@ -88,7 +88,8 @@ export async function walkPass(
|
||||
seen: string[],
|
||||
keep: (name: string) => boolean,
|
||||
jump: () => string | null,
|
||||
onDir?: (rel: string) => void
|
||||
onDir?: (rel: string) => void,
|
||||
onFile?: (file: WalkFile) => void
|
||||
): Promise<boolean> {
|
||||
for (let i = 0; i < DIRS_PER_PASS && walk.pending.length; i++) {
|
||||
await jumpQueue(walk, jump());
|
||||
@@ -107,7 +108,9 @@ export async function walkPass(
|
||||
walk.pending.push({ dir: entry as FileSystemDirectoryHandle, rel });
|
||||
seen.push(rel);
|
||||
} else if (keep(entry.name)) {
|
||||
out.push({ handle: entry as FileSystemFileHandle, rel: `${baseRel}${entry.name}` });
|
||||
const file: WalkFile = { handle: entry as FileSystemFileHandle, rel: `${baseRel}${entry.name}` };
|
||||
out.push(file);
|
||||
onFile?.(file);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user