commit cc70080585a9fe8c0810d1eb85052edbc57a3cd9
parent 539d3a878e2825ea58587c2d2c8ca5e99e5b2a3d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 28 Sep 2026 18:42:32 -0400
common: buildIndex records when its last completed scan began
`meta.scannedAt` (INDEX_SCANNED_AT_KEY, in lib/stats.ts so buildStats need
not load the index builder), written only when a build completes. buildStats
reads it to tell a video downloaded since the last index build from one that
build saw and did not index. Additive: the index schema does not move.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/common/controller/buildIndex.ts b/common/controller/buildIndex.ts
@@ -64,6 +64,7 @@ import {
pageFileName,
} from "../lib/manifest";
import { getSettings } from "../lib/settings";
+import { INDEX_SCANNED_AT_KEY } from "../lib/stats";
import {
listSites,
siteDigestsDir,
@@ -556,6 +557,11 @@ export async function buildIndex({
await meta.put("schema", SCHEMA_VERSION);
}
+ // Recorded as INDEX_SCANNED_AT_KEY only when this build completes, so
+ // buildStats can tell apart a video with no `mtimes` record: metadata newer
+ // than this is "not indexed yet"; older, and this build saw it and skipped it
+ // (no upload_date, or processing failed).
+ const scanStartedAt = Date.now();
const { live, channels: channelConfigs } = await scanSource(channelsDir, log);
const livePathIds = new Set<string>();
const liveByPathId = new Map<string, LiveEntry>();
@@ -1997,6 +2003,7 @@ export async function buildIndex({
}
}
for (const k of staleFpKeys) meta.remove(k);
+ await meta.put(INDEX_SCANNED_AT_KEY, scanStartedAt);
await meta.flushed;
await root.close();
diff --git a/common/lib/stats.ts b/common/lib/stats.ts
@@ -11,6 +11,13 @@ import type { VideoState } from "./availability";
export const STATS_SCHEMA_VERSION = 6;
export const STATS_MANIFEST_VERSION = 1;
+// A key in buildIndex's `meta` sub-DB (not this cache's): the ms timestamp the
+// last COMPLETED index build's scan began at. buildIndex writes it; buildStats
+// reads it to tell a video downloaded since that scan from one the scan saw and
+// did not index. Here rather than in buildIndex.ts so buildStats need not load
+// the index builder. Additive: the index schema did not move.
+export const INDEX_SCANNED_AT_KEY = "scannedAt";
+
// Visibility of a video on its source platform. One type with the viewer's, so
// the status chart and the search filter can never drift apart; see VideoState
// in lib/availability for the taxonomy (available + the five missing leaves).