commit 019aaca39dee45f3c9b66e97c67f4243c59e336d
parent 7c46076d8561aeb07573eaa58ece35c61d60c3b1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 09:08:22 -0500
local media: a local recording's id includes its channel
Review fix 6, before any record exists. localRecordingId hashed only the
library id and the file name, so two channels with the same library id
("library-1" is the default) and a same-named file got the same
`local-...` id: one id for two records across the corpus. The channel slug
is now part of the hash. Fixtures updated; a test pins two channels, two ids.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/common/controller/localMediaImport.ts b/common/controller/localMediaImport.ts
@@ -73,9 +73,9 @@ export async function previewLocalMedia(paths: ImportPaths, slug: string): Promi
// A recording without provider metadata has the same reserved identity
// before and after subtitle generation. Never offer generation over an
// existing local record, even if that record is incomplete.
- if (row.transcriptionNeedsDetails && entries.includes(localRecordingId(c.config.sourceId, row.media))) {
+ if (row.transcriptionNeedsDetails && entries.includes(localRecordingId(slug, c.config.sourceId, row.media))) {
row.generatedMetadata = true;
- row.directoryId = localRecordingId(c.config.sourceId, row.media);
+ row.directoryId = localRecordingId(slug, c.config.sourceId, row.media);
row.recordId = row.directoryId;
row.status = "existing";
row.issues = [];
@@ -85,7 +85,7 @@ export async function previewLocalMedia(paths: ImportPaths, slug: string): Promi
}
if (row.preparationFingerprint) {
row.generatedMetadata = true;
- row.directoryId = localRecordingId(c.config.sourceId, row.media);
+ row.directoryId = localRecordingId(slug, c.config.sourceId, row.media);
row.recordId = row.directoryId;
if (entries.includes(row.directoryId)) {
// A generated record is reserved by library/name, so rescanning or a
@@ -252,7 +252,7 @@ async function preparedBytes(paths: ImportPaths, slug: string,
if (await optionalStat(path.join(c.source, row.metadata))) throw new Error("Metadata appeared; preview again");
const transcript = await readLocalMediaText(c.source, row.transcript);
if (localMediaFingerprint(row.media, "", localTranscriptFingerprint(row.transcript, transcript), before) !== request.sourceFingerprint) throw new Error("Source changed");
- const input = {id: localRecordingId(c.config.sourceId, row.media), filename: row.media,
+ const input = {id: localRecordingId(slug, c.config.sourceId, row.media), filename: row.media,
title: details.title, recordedDate: details.recordedDate};
// Only server configuration chooses the executable. Inspection failure
// never silently turns into manual preparation.
diff --git a/common/controller/localMediaPreparation.test.ts b/common/controller/localMediaPreparation.test.ts
@@ -119,7 +119,7 @@ test("missing ffprobe fails explicitly; manual preparation and stable identity r
const second = await prepareLocalMediaRecording(f.paths, "sample", {...f.request, details: {mode:"manual",title:"Changed title",durationSeconds:3,recordedDate:"2026-01-01"}});
assert.equal(first.metadata.id, second.metadata.id);
assert.notEqual(first.fingerprint, second.fingerprint);
- assert.equal(first.metadata.id, localRecordingId("library-1", f.media));
+ assert.equal(first.metadata.id, localRecordingId("sample", "library-1", f.media));
assert.deepEqual(await readdir(f.channel), ["config.json"]);
});
@@ -154,3 +154,13 @@ test("queued detail snapshots allow only intended fields and manual durations",
assert.throws(() => parseLocalRecordingDetails(bad));
}
});
+
+// Review fix 6: a local recording's id is unique across channels — the same
+// library id and file name in two channels are two records.
+test("localRecordingId includes the channel: same library and file in two channels, two ids", () => {
+ const a = localRecordingId("channel-a", "library-1", "talk.mp4");
+ const b = localRecordingId("channel-b", "library-1", "talk.mp4");
+ assert.notEqual(a, b);
+ assert.match(a, /^local-[0-9a-f]{32}$/);
+ assert.equal(a, localRecordingId("channel-a", "library-1", "talk.mp4"));
+});
diff --git a/common/controller/localTranscriptionEligibility.test.ts b/common/controller/localTranscriptionEligibility.test.ts
@@ -88,7 +88,7 @@ test("invalid metadata, source media links and duplicate identities cannot quali
test("occupied generated and provider identities are blocked even with incomplete saved records", async t => {
const f=await fixture(t);
- const id=localRecordingId("library-1","lesson.mp4");
+ const id=localRecordingId("sample","library-1","lesson.mp4");
await mkdir(path.join(f.channel,"data",id),{recursive:true});
assert.equal((await f.preview()).candidates[0].transcriptionFingerprint,undefined);
await writeFile(path.join(f.source,"lesson.info.json"),JSON.stringify(metadata()));
diff --git a/common/lib/localRecordingDetails.ts b/common/lib/localRecordingDetails.ts
@@ -10,8 +10,11 @@ export type LocalRecordingDetails = {
// Stable within one channel's configured library. Changing editable facts or
// retrying a queued import cannot create another ID. Renaming an original is a
// different source selection; this is identity assignment, not deduplication.
-export function localRecordingId(sourceId: string, media: string): string {
- return "local-" + createHash("sha256").update(JSON.stringify(["local-recording-v1", sourceId, media])).digest("hex").slice(0, 32);
+// The CHANNEL is part of it (lane/local-media review fix 6): two channels with
+// the same library id and file name are two records, never one id across the
+// corpus (an index key, a citation and a clip all name a record by its id).
+export function localRecordingId(channelSlug: string, sourceId: string, media: string): string {
+ return "local-" + createHash("sha256").update(JSON.stringify(["local-recording-v1", channelSlug, sourceId, media])).digest("hex").slice(0, 32);
}
export function parseLocalRecordingDetails(value: unknown): LocalRecordingDetails {