commit e6134f32398b9fbcd186cdfffe63e5627e80f9a5
parent 845d2eaeb0b51f04e41c65f0b0ccbb259fc4c5b1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 26 Oct 2026 23:32:47 -0400
chunked encode: the content-hash memo forgets files the cut no longer reads
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -4873,6 +4873,9 @@ async function chunkedXfadeConcat({ segments, render, outPath, chrome = null, jo
version: 1, builtAt: new Date().toISOString(), frames: N, fps, audio: path.basename(audio),
chunks: plan.map((p) => p.rec),
}, null, 2) + "\n", "utf8");
+ // The memo keeps what this cut is made of: a frame or segment gone is forgotten.
+ memo.pruneUnseen();
+ await memo.save();
const keep = new Set([...plan.map((p) => path.basename(p.file)), path.basename(audio), CHUNKS_RECORD, "concat.txt"]);
for (const name of await readdir(dir)) if (!keep.has(name)) await rm(path.join(dir, name), { force: true });
diff --git a/umtool/report-to-video/chunked-encode.mjs b/umtool/report-to-video/chunked-encode.mjs
@@ -136,6 +136,7 @@ export class HashMemo {
this.dirty = false;
this.hashed = 0;
this.bytes = 0;
+ this.seen = new Set();
}
static async open(file) {
@@ -157,6 +158,7 @@ export class HashMemo {
const st = await stat(file).catch(() => null);
if (!st?.isFile()) return null;
const id = `${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}`;
+ this.seen.add(id);
const had = this.map.get(id);
if (had) return had;
const h = createHash("sha1").update(await readFile(file)).digest("hex");
@@ -187,6 +189,11 @@ export class HashMemo {
return out;
}
+ /** Forget every file not hashed (or found) since the memo was opened. */
+ pruneUnseen() {
+ this.prune((id) => this.seen.has(id));
+ }
+
/** Keep only the entries `keep` says to (`(id) => boolean`). */
prune(keep) {
for (const k of [...this.map.keys()]) {