diff --git a/docker/frontend/src/engine/immich.ts b/docker/frontend/src/engine/immich.ts index baf2c51..80bd10d 100644 --- a/docker/frontend/src/engine/immich.ts +++ b/docker/frontend/src/engine/immich.ts @@ -326,7 +326,13 @@ export async function syncImmich( const chosen = folder.albums ?? []; const root = normPath(folder.name); - const rows: LibraryPhoto[] = []; + // Every row this reading met, spelled the way `prunePhotos` spells one. It is + // the whole reading that is written down here — the foreground's pages and the + // pages behind them — because a node bigger than one visit is read in two + // passes, and a prune held against the first pass alone takes back every frame + // the second one filed: the node the reader is left with is the newest three + // pages of it, for good, and its place says the reading is done. + const met = new Set(); const dirs: LibraryDir[] = []; const counts: Record = {}; // The frames this reading has already filed. The keyset read stops on a frame's @@ -411,7 +417,7 @@ export async function syncImmich( size: item.size ?? 0, addedAt: Date.now(), }; - rows.push(row); + met.add(name.toLowerCase()); batchRows.push(row); rootCount++; } @@ -475,7 +481,7 @@ export async function syncImmich( size: item.size ?? 0, addedAt: Date.now(), }; - rows.push(row); + met.add(`${normPath(label)}/${name}`.toLowerCase()); albBatch.push(row); albCount++; } @@ -500,14 +506,12 @@ export async function syncImmich( // A row the reading did not meet is dropped only against a reading that met all // of them — and only one that began at the top. A reading that carried on from - // where the last one stopped holds the newest pages in its own list and no older - // row in it at all, and pruned to that list it would take back every frame it - // was picking up. + // where the last one stopped met the older pages alone and not one of the newest, + // and pruned to what it met it would take back every frame it was picking up. // ponytail: a resumed reading therefore stops one prune short — a frame dropped // on the server keeps its row until some visit reads the node from the top. Read - // `met` out of the catalogue rather than out of `rows` if that ever shows. + // the catalogue rather than the reading if that ever shows. if (complete && !failed && !resume) { - const met = new Set(rows.map((r) => (r.dir ? `${normPath(r.dir)}/${r.name}` : r.name).toLowerCase())); await prunePhotos(root, '', met); } @@ -544,6 +548,7 @@ export async function syncImmich( const name = frameName(item.name, item.id, rootTaken); rootTaken.add(item.name); rootTaken.add(name); + met.add(name.toLowerCase()); bgBatchRows.push({ id: [root, name].join('/'), folder: folder.name, @@ -579,7 +584,6 @@ export async function syncImmich( // added since would be. await remember(null, 1, true); if (!resume) { - const met = new Set(rows.map((r) => (r.dir ? `${normPath(r.dir)}/${r.name}` : r.name).toLowerCase())); await prunePhotos(root, '', met); } }