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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): throw on unreadable legacy file so the split retries
[._.]/ Adam Eivy2efee92b7a15
diff --git a/scripts/migrations/059-split-media-collections.js b/scripts/migrations/059-split-media-collections.jsindex 9ab04fb004..8690cdb28f 100644--- a/scripts/migrations/059-split-media-collections.js+++ b/scripts/migrations/059-split-media-collections.js@@ -121,8 +121,14 @@ export default {const sourcePath = legacyExists ? legacyPath : backupPath;const doc = await readJsonTolerant(sourcePath);if (!doc || typeof doc !== 'object' || doc.__unreadable) {- console.warn(`⚠️ migration 059: ${sourcePath} unreadable — skipping. Resolve manually before next boot.`);- return { ok: false, reason: 'unreadable' };+ // THROW (don't return) so the runner does NOT mark this migration applied+ // — it records any migration whose up() *resolves* (run-migrations.js:70-71),+ // so returning here would freeze the split as "done" with nothing migrated,+ // and the collections would stay orphaned in the unreadable file even after+ // the user repairs it. Throwing keeps it pending so a repaired file is+ // re-split on the next boot; server boot itself survives via the+ // runMigrations().catch() in server/index.js.+ throw new Error(`migration 059: ${sourcePath} is unreadable — repair or remove it, then reboot to retry the split`);}const collections = Array.isArray(doc.collections) ? doc.collections : [];diff --git a/scripts/migrations/059-split-media-collections.test.js b/scripts/migrations/059-split-media-collections.test.jsindex d51104a02c..1369379e22 100644--- a/scripts/migrations/059-split-media-collections.test.js+++ b/scripts/migrations/059-split-media-collections.test.js@@ -155,10 +155,14 @@ describe('migration 059 — split media-collections.json to per-record files', (expect(readJson(join(typeDir, id, 'index.json')).name).toBe('First (wins)');});- it('reports unreadable when the legacy file is corrupted', async () => {+ it('throws (does NOT mark applied) when the legacy file is corrupted, so a repaired file re-splits', async () => {+ // Throwing keeps the migration pending in run-migrations.js (which marks any+ // migration whose up() resolves as applied) — so the collections aren't+ // frozen as "migrated" while still trapped in the unreadable file.writeFileSync(legacyPath, 'not json');- const result = await migration.up({ rootDir });- expect(result.ok).toBe(false);+ await expect(migration.up({ rootDir })).rejects.toThrow(/unreadable/);+ // Nothing was stamped — a repaired file on the next run still splits.+ expect(existsSync(typeIndexPath)).toBe(false);});it('recovers from the .bak-059 file if the legacy was already renamed', async () => {