Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

perf: defer reconcile-only paths from indexed gallery reads (#7040)

[._.]/ Adam Eivyd0769c5b6797
diff --git a/server/services/mediaAssetIndex/db.js b/server/services/mediaAssetIndex/db.js
index 8bc82b4143..ca1d317942 100644
--- a/server/services/mediaAssetIndex/db.js
+++ b/server/services/mediaAssetIndex/db.js
@@ -26,7 +26,6 @@ import { readFile } from 'fs/promises';
import { join } from 'path';
import { query } from '../../lib/db.js';
import { dedupeByKey } from '../../lib/arrayUtils.js';
-import { PATHS } from '../../lib/fileUtils.js';
import { imageToRow, videoToRow } from './logic.js';
function rowToAsset(row) {
@@ -136,7 +135,10 @@ export async function countAssets(filters = {}) {
// wipe every video row whose file is still on disk. This reader distinguishes
// the two: file absent → genuinely empty (ok); present-but-unparseable → failure
// (not ok), so the caller skips pruning videos. Returns { ok, list }.
-export async function readVideoHistoryStrict(historyPath = join(PATHS.data, 'video-history.json')) {
+export async function readVideoHistoryStrict(historyPath) {
+ // Only reconcile needs filesystem paths; indexed list reads do not. Keep the
+ // facade specifier so existing test path overrides still intercept it.
+ historyPath ??= join((await import('../../lib/fileUtils.js')).PATHS.data, 'video-history.json');
// Read with explicit error-code handling — NOT tryReadFile/readJSONFile, which
// both collapse "missing" and "unreadable" to the same value. Only a genuine
// ENOENT (file never written) counts as trusted-empty; an EACCES/EIO/transient