fix: handle missing archive/legacy dir on first compaction run

listAllFiles('archive/legacy') throws 404 EntryNotFound when the
directory doesn't exist yet on HF. Catch it so the first run
proceeds instead of dying at Step 2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
faber
2026-07-14 09:59:17 -04:00
parent 9f714a09fc
commit 2e1cf58343

View File

@@ -146,7 +146,12 @@ async function main() {
console.log(`Step 2: Checking for existing manifest (run ID: ${currentRunId})...`);
// Also check if a DIFFERENT run's manifest exists (partial deletion scenario)
const archiveLegacyEntries = await listAllFiles('archive/legacy', true);
let archiveLegacyEntries = [];
try {
archiveLegacyEntries = await listAllFiles('archive/legacy', true);
} catch (err) {
if (!/404|EntryNotFound|does not exist/i.test(String(err.message))) throw err;
}
const existingManifests = archiveLegacyEntries.filter(
f => f.type === 'file' && f.path.endsWith('/manifest.json')
);