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

fix: adopt a pre-May-2026 migration ledger when restoring an older backup

[._.]/ Adam Eivy043560ca42d6
diff --git a/client/src/components/BackupWidget.jsx b/client/src/components/BackupWidget.jsx
index 0831f052a6..9290c6f86f 100644
--- a/client/src/components/BackupWidget.jsx
+++ b/client/src/components/BackupWidget.jsx
@@ -159,7 +159,10 @@ function RestorePanel({ snapshot, onClose, restoring, onRestoreStateChange }) {
const suffix = result.verification?.status === 'unverified' ? ' (unverified legacy snapshot)' : '';
const parked = (result.restoredLegacyStores ?? []).filter(store => store.parkedAs).map(store => store.parkedAs);
const conversion = parked.length > 0 ? `. Converted older-format data; the replaced stores were kept as ${parked.join(', ')}` : '';
- toast.success(`File restore complete — ${result.changedFiles?.length ?? 0} file(s) restored${suffix}${conversion}`);
+ const ledger = result.restoredLegacyLedger?.status === 'adopted'
+ ? `. Adopted the snapshot's migration record${result.restoredLegacyLedger.parkedAs ? ` (previous record kept as ${result.restoredLegacyLedger.parkedAs})` : ''}; restart PortOS to re-run the migrations it predates`
+ : '';
+ toast.success(`File restore complete — ${result.changedFiles?.length ?? 0} file(s) restored${suffix}${conversion}${ledger}`);
onClose();
}
}, [acceptedPreview, onClose, onRestoreStateChange, previewMatchesCurrentRequest, restoring, snapshot]);
@@ -266,6 +269,14 @@ function RestorePanel({ snapshot, onClose, restoring, onRestoreStateChange }) {
</span>
</p>
)}
+ {preview.restoredLegacyLedger && (
+ <p className="mb-2 flex items-start gap-1.5 rounded border border-port-warning/40 bg-port-warning/10 p-2 text-xs text-port-warning" role="alert">
+ <AlertTriangle size={13} className="mt-0.5 shrink-0" />
+ <span className="min-w-0 break-words">
+ This snapshot keeps its migration record in the older <code>migrations/.applied.json</code> location. Restoring installs it as this install&apos;s record (the current one is kept as <code>migrations.applied.json.pre-restore-&lt;time&gt;</code>) so the next start re-runs every migration the snapshot predates.
+ </span>
+ </p>
+ )}
{preview.restoredLegacyStores?.length > 0 && (
<p className="mb-2 flex items-start gap-1.5 rounded border border-port-warning/40 bg-port-warning/10 p-2 text-xs text-port-warning" role="alert">
<AlertTriangle size={13} className="mt-0.5 shrink-0" />
diff --git a/client/src/components/BackupWidget.test.jsx b/client/src/components/BackupWidget.test.jsx
index 71c2c4a23d..1975249d2a 100644
--- a/client/src/components/BackupWidget.test.jsx
+++ b/client/src/components/BackupWidget.test.jsx
@@ -380,6 +380,28 @@ describe('BackupWidget snapshots', () => {
));
});
+ it('announces a pre-May-2026 ledger adoption and asks for a restart afterwards', async () => {
+ mockRestoreBackup
+ .mockResolvedValueOnce({
+ dryRun: true,
+ changedFiles: ['migrations/.applied.json'],
+ restoredLegacyLedger: { status: 'pending', parkedAs: null },
+ })
+ .mockResolvedValueOnce({
+ changedFiles: ['migrations/.applied.json'],
+ restoredLegacyLedger: { status: 'adopted', parkedAs: 'migrations.applied.json.pre-restore-example' },
+ });
+ renderWidget();
+ await openRestorePanel();
+ fireEvent.click(screen.getByRole('button', { name: 'Preview changes' }));
+
+ expect(await screen.findByRole('alert')).toHaveTextContent(/older migrations\/\.applied\.json location.*re-runs every migration/);
+ fireEvent.click(screen.getByRole('button', { name: 'Restore 1 file(s)' }));
+ await waitFor(() => expect(mockToast.success).toHaveBeenCalledWith(
+ "File restore complete — 1 file(s) restored. Adopted the snapshot's migration record (previous record kept as migrations.applied.json.pre-restore-example); restart PortOS to re-run the migrations it predates",
+ ));
+ });
+
it('shows no migration warning for a gap that is empty or unknown', async () => {
mockRestoreBackup
.mockResolvedValueOnce({ changedFiles: ['cos/quota-burn.json'], ledgerGap: { count: 0, names: [] } })
diff --git a/docs/BACKUP.md b/docs/BACKUP.md
index 86a8f24018..9f9c79cba3 100644
--- a/docs/BACKUP.md
+++ b/docs/BACKUP.md
@@ -517,7 +517,7 @@ A snapshot taken before the agent records moved into PostgreSQL (#12738) also ca
Keep the original backup intact. Copy it into a disposable offline install running the compatible historical version, upgrade that isolated install through the file-to-database transition, and verify the imported records and linked files there. Make a current-format file and PostgreSQL backup from the converted install, then use the normal verified restore workflow. Do not convert against the live database or delete its markers. Current file-primary siblings (such as manuscript reviews, draft Markdown and media assets) and parked `.imported` recovery evidence remain eligible for file restore. Selecting one of those siblings is allowed even if another part of the snapshot contains legacy metadata.
-A full restore also installs the snapshot's `migrations.applied.json`, so the next start re-runs every file migration the snapshot predates. That re-run only upgrades restored files for migrations gated on their input. The store-split migrations (059 for media collections, 200 for the Brain stores) gate on their output, a type index already at schema v1, and file restore leaves the live index in place, so their re-run is a no-op over a restored monolith. Restore therefore converts those stores itself (#12626): when the scope covers a store (full restore, `brain`, `brain/<type>.json`, `media-collections` or `media-collections.json`) and the snapshot carries its monolith (`brain/<type>.json`, `media-collections.json`) without `<store>/index.json`, a successful transfer moves the live `<store>/` directory to `<store>.pre-restore-<timestamp>/` (and a live `.bak-200`/`.bak-059` backup beside it), runs the frozen split migration against the install, and invalidates the Brain caches. The restored records, tombstones included, then load immediately, for folder restores too. A snapshot that has the split layout plus a stray monolith (setup-data re-seeds those after an upgrade) is current and is not converted. A monolith the split would refuse (unparseable, or a malformed records container) is restored as-is and never parks the live store. Preview and result list these stores in `restoredLegacyStores` (`{ store, legacyFile, status, parkedAs }`, with `status` `pending` in a preview and `converted` or `unreadable` after execution); the widget warns before restore and names the parked directory afterwards. A folder restore (`subdirFilter`) keeps the live ledger, so restored files can come back in a shape older than migrations no runner will revisit. Its preview and result therefore carry `ledgerGap`: `{ count, names }` listing the migrations the live ledger records and the snapshot's lacks, or `null` when either ledger is missing or unreadable. A full restore omits the field. The widget warns on a non-empty gap and recommends a full restore, but does not refuse: a folder no migration touched restores correctly. The quota-burn plan is converted on the spot: a restore covering `cos/quota-burn.json` (full, `cos`, or that file) runs any legacy `jobType` steps through the same conversion as migration 359 (`reconcileRestoredQuotaBurnPlan`), reusing each step's deterministic `job-burn-<family>-<step>` custom job, so a repeated restore creates no duplicates.
+A full restore also installs the snapshot's `migrations.applied.json`, so the next start re-runs every file migration the snapshot predates. A snapshot taken before migrations moved out of `data/` (May 2026) carries that ledger at `migrations/.applied.json` instead; the transfer lands it beside the live `migrations.applied.json`, which the runner would then keep, so a full restore adopts it by hand after the transfer: the live ledger is parked as `migrations.applied.json.pre-restore-<timestamp>` and the restored one takes its place. Preview and result carry `restoredLegacyLedger` (`{ status, parkedAs }`, `pending` in a preview and `adopted` after execution); the widget warns before restore and asks for a restart afterwards. A snapshot that also carries a current-path ledger is left to the transfer. That re-run only upgrades restored files for migrations gated on their input. The store-split migrations (059 for media collections, 200 for the Brain stores) gate on their output, a type index already at schema v1, and file restore leaves the live index in place, so their re-run is a no-op over a restored monolith. Restore therefore converts those stores itself (#12626): when the scope covers a store (full restore, `brain`, `brain/<type>.json`, `media-collections` or `media-collections.json`) and the snapshot carries its monolith (`brain/<type>.json`, `media-collections.json`) without `<store>/index.json`, a successful transfer moves the live `<store>/` directory to `<store>.pre-restore-<timestamp>/` (and a live `.bak-200`/`.bak-059` backup beside it), runs the frozen split migration against the install, and invalidates the Brain caches. The restored records, tombstones included, then load immediately, for folder restores too. A snapshot that has the split layout plus a stray monolith (setup-data re-seeds those after an upgrade) is current and is not converted. A monolith the split would refuse (unparseable, or a malformed records container) is restored as-is and never parks the live store. Preview and result list these stores in `restoredLegacyStores` (`{ store, legacyFile, status, parkedAs }`, with `status` `pending` in a preview and `converted` or `unreadable` after execution); the widget warns before restore and names the parked directory afterwards. A folder restore (`subdirFilter`) keeps the live ledger, so restored files can come back in a shape older than migrations no runner will revisit. Its preview and result therefore carry `ledgerGap`: `{ count, names }` listing the migrations the live ledger records and the snapshot's lacks, or `null` when either ledger is missing or unreadable. A full restore omits the field. The widget warns on a non-empty gap and recommends a full restore, but does not refuse: a folder no migration touched restores correctly. The quota-burn plan is converted on the spot: a restore covering `cos/quota-burn.json` (full, `cos`, or that file) runs any legacy `jobType` steps through the same conversion as migration 359 (`reconcileRestoredQuotaBurnPlan`), reusing each step's deterministic `job-burn-<family>-<step>` custom job, so a repeated restore creates no duplicates.
**Every nonzero rsync exit fails a restore, including 24.** A backup tolerates exit 24 ("some source files vanished") because it reads the live data tree, where a file deleted mid-scan is normal. A restore reads a snapshot that must not change under it, so a vanished source file means live data may now mix restored and older files: preview and execution both reject it. An execution failure is reported as a partial restore — the error says some files may already have been overwritten because file restore is not transactional — and caches (settings, Brain, media index) are reconciled before the error is returned, exactly as for any other failed transfer.
diff --git a/server/services/backup.js b/server/services/backup.js
index 3bc5a9ae1d..ba8b31d349 100644
--- a/server/services/backup.js
+++ b/server/services/backup.js
@@ -9,11 +9,11 @@
import { dashboardEvents } from './dashboardEvents.js';
import { spawn } from '../lib/childProcess.js';
import { killWithEscalation } from '../lib/killWithEscalation.js';
-import { access, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, stat, unlink, writeFile } from 'fs/promises';
+import { access, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rename, rm, stat, unlink, writeFile } from 'fs/promises';
import { randomUUID } from 'node:crypto';
import { PassThrough } from 'node:stream';
import { hostname, tmpdir } from 'os';
-import { basename, join, resolve, relative, isAbsolute } from 'path';
+import { basename, dirname, join, resolve, relative, isAbsolute } from 'path';
import { PATHS, ensureDir, readJSONFile, readJSONFileStrict, atomicWrite, sha256File } from '../lib/fileUtils.js';
import { createFileWriteQueue } from '../lib/fileWriteQueue.js';
import { acquireBackupSnapshotCut } from '../lib/backupSnapshotBoundary.js';
@@ -29,6 +29,7 @@ import {
restoreRecoveryRefusal, settleReplayOutcome,
} from './backupRestoreRecovery.js';
import { getBackendName } from './memoryBackend.js';
+import { appliedFilePath, legacyAppliedFilePath } from '../../scripts/lib/migrationLedger.js';
import { emitErrorEvent, ServerError } from '../lib/errorHandler.js';
import { isSafeSnapshotSource, isSafeSubdirFilter, anchorUserExcludes } from '../lib/sharedSchemas.js';
import { reloadSettings, withLiveSettingsRestore } from './settings.js';
@@ -856,6 +857,16 @@ export async function runBackup(destPath, io = null, { excludePaths = [], disabl
* no installed pg_dump is new enough for the running server)
* @param {string} outputPath - Path to write the SQL dump file
*/
+/**
+ * The explicit file escape hatch (MEMORY_BACKEND=file, or a backend that
+ * resolved to 'file'): the one state in which PostgreSQL is not required. The
+ * backend initializes lazily (ensureBackend), so the env var is consulted too —
+ * an uninitialized backend under the hatch must not count as "Postgres required".
+ * Shared by the dump, the restore compatibility check and restore reconciliation
+ * so the three cannot disagree about one install.
+ */
+const usesFileEscapeHatch = () => process.env.MEMORY_BACKEND === 'file' || getBackendName() === 'file';
+
export async function dumpPostgres(outputPath) {
const health = await checkHealth();
if (!health.connected || !health.hasSchema) {
@@ -869,9 +880,7 @@ export async function dumpPostgres(outputPath) {
// rather than silently skip; gating on getBackendName() === 'postgres'
// alone would let an outage-before-first-memory-access read as a green
// "not configured" run.
- const env = process.env.MEMORY_BACKEND;
- const fileEscapeHatch = env === 'file' || getBackendName() === 'file';
- if (!fileEscapeHatch) {
+ if (!usesFileEscapeHatch()) {
return { status: 'failed', reason: 'pg_unreachable', error: health.error || 'PostgreSQL is required but is unreachable or uninitialized' };
}
return { status: 'skipped', reason: 'not_configured' };
@@ -1486,7 +1495,7 @@ async function reconcileLiveFileRestore(subdirFilter) {
{ label: 'settings reload', run: reloadSettings },
...((!subdirFilter || ['images', 'videos', 'video-thumbnails', 'video-history.json']
.some(path => subdirFilter === path || subdirFilter.startsWith(`${path}/`)))
- && getBackendName() !== 'file'
+ && !usesFileEscapeHatch()
? [{ label: 'media index rebuild', run: async () => {
const { reconcileMediaAssets } = await import('./mediaAssetIndex/db.js');
await reconcileMediaAssets({ rebuild: true });
@@ -1735,7 +1744,7 @@ const LEGACY_DB_METADATA = [
async function assertRestoreStorageCompatible(srcDir, inventory, snapshotId) {
// Match dumpPostgres: an uninitialized backend still requires PostgreSQL.
- if (process.env.MEMORY_BACKEND === 'file' || getBackendName() === 'file') return;
+ if (usesFileEscapeHatch()) return;
if (!inventory) throw snapshotFileIntegrityError(snapshotId);
const domains = new Set(LEGACY_DB_METADATA
.filter(([, pattern]) => inventory.paths.some(path => pattern.test(path)))
@@ -1896,9 +1905,11 @@ async function restoreHeldSnapshot({ snapshotDir, currentSource }, snapshotId, {
// Split migrations gate on their output, so neither ledger re-runs them over
// a restored monolith; restore converts those stores itself (#12626).
const legacyStores = await snapshotLegacySplitStores(srcDir, subdirFilter);
- const restoreNotes = (restoredLegacyStores) => ({
+ const legacyLedger = await snapshotLegacyLedger(srcDir, subdirFilter);
+ const restoreNotes = (restoredLegacyStores, restoredLegacyLedger = legacyLedger) => ({
...(ledgerGap !== undefined && { ledgerGap }),
...(restoredLegacyStores.length > 0 && { restoredLegacyStores }),
+ ...(restoredLegacyLedger && { restoredLegacyLedger }),
...(identity.preserved && { identityPreserved: identity.preserved }),
...(identity.adopted && { identityAdopted: identity.adopted }),
});
@@ -1960,6 +1971,7 @@ async function restoreHeldSnapshot({ snapshotDir, currentSource }, snapshotId, {
const scope = subdirFilter;
let restoredLegacyStores = [];
+ let restoredLegacyLedger = legacyLedger;
// Conversion parks live stores, so it runs only after a successful transfer,
// and before reconciliation so the Brain caches drop the parked records.
const changedFiles = await withLiveFileRestoreOwners(scope, srcDir, () => transferAndReconcileLiveFiles({
@@ -1974,19 +1986,66 @@ async function restoreHeldSnapshot({ snapshotDir, currentSource }, snapshotId, {
transferFiles,
});
restoredLegacyStores = await convertRestoredLegacySplitStores(legacyStores);
+ if (legacyLedger) restoredLegacyLedger = await adoptRestoredLegacyLedger();
return changed;
},
}));
- return { dryRun, snapshotId, subdirFilter, changedFiles, verification, ...restoreNotes(restoredLegacyStores) };
+ return { dryRun, snapshotId, subdirFilter, changedFiles, verification, ...restoreNotes(restoredLegacyStores, restoredLegacyLedger) };
}
-const MIGRATION_LEDGER_FILE = 'migrations.applied.json';
-
async function readMigrationLedger(path) {
const { ok, value } = await readJSONFileStrict(path, null, { logError: false });
return ok && Array.isArray(value) ? value.filter(name => typeof name === 'string') : null;
}
+// The ledger helpers take an install root and join `data/` themselves; a
+// snapshot's data directory and the live one both sit one level below theirs.
+const ledgerPaths = (dataDir) => ({ current: appliedFilePath(dirname(dataDir)), legacy: legacyAppliedFilePath(dirname(dataDir)) });
+
+/**
+ * The snapshot's migration ledger: `data/migrations.applied.json`, or the
+ * `data/migrations/.applied.json` a snapshot from before the May 2026 move of
+ * migrations out of `data/` still carries. Null when neither is readable.
+ */
+async function readSnapshotMigrationLedger(srcDir) {
+ const { current, legacy } = ledgerPaths(srcDir);
+ return await readMigrationLedger(current) ?? readMigrationLedger(legacy);
+}
+
+/**
+ * Whether a full restore of this snapshot must adopt its ledger by hand: the
+ * snapshot carries the ledger only at the legacy path. rsync lands that file
+ * beside the live `migrations.applied.json` instead of over it, and the runner
+ * then keeps the live ledger (a current ledger is authoritative over a legacy
+ * one), so nothing would re-run over the restored records (#12355 assumed the
+ * two paths coincide). Null when the snapshot carries a current ledger or none.
+ */
+async function snapshotLegacyLedger(srcDir, subdirFilter) {
+ if (subdirFilter) return null;
+ const { current, legacy } = ledgerPaths(srcDir);
+ const present = (path) => stat(path).then(info => info.isFile(), error => { if (error.code === 'ENOENT') return false; throw error; });
+ return !(await present(current)) && await present(legacy) ? { status: 'pending', parkedAs: null } : null;
+}
+
+/**
+ * Install the restored legacy ledger as the live one, after the transfer and
+ * before cache reconciliation: the live ledger is parked beside it (evidence,
+ * like a parked split store), and the next migration run starts from the
+ * snapshot's list, exactly as a full restore with a current-path ledger does.
+ */
+async function adoptRestoredLegacyLedger() {
+ const { current, legacy } = ledgerPaths(PATHS.data);
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
+ const parkedAs = `${basename(current)}.pre-restore-${stamp}`;
+ const parked = await rename(current, join(dirname(current), parkedAs)).then(
+ () => true,
+ error => { if (error.code === 'ENOENT') return false; throw error; },
+ );
+ await rename(legacy, current);
+ console.log(`📦 Restore adopted the snapshot's pre-May-2026 migration ledger${parked ? `; previous ledger parked as ${parkedAs}` : ''}`);
+ return { status: 'adopted', parkedAs: parked ? parkedAs : null };
+}
+
/**
* Migrations the live install has applied that the snapshot's ledger lacks:
* files a folder restore installs from that snapshot may predate them, and no
@@ -1994,8 +2053,8 @@ async function readMigrationLedger(path) {
* unknown — the snapshot (or the live install) has no readable ledger.
*/
async function migrationLedgerGap(srcDir) {
- const snapshotLedger = await readMigrationLedger(join(srcDir, MIGRATION_LEDGER_FILE));
- const liveLedger = snapshotLedger && await readMigrationLedger(join(PATHS.data, MIGRATION_LEDGER_FILE));
+ const snapshotLedger = await readSnapshotMigrationLedger(srcDir);
+ const liveLedger = snapshotLedger && await readMigrationLedger(ledgerPaths(PATHS.data).current);
if (!snapshotLedger || !liveLedger) return null;
const recorded = new Set(snapshotLedger);
const names = liveLedger.filter(name => !recorded.has(name));
diff --git a/server/services/backup.test.js b/server/services/backup.test.js
index 9335dce1f6..d883dc76bd 100644
--- a/server/services/backup.test.js
+++ b/server/services/backup.test.js
@@ -2564,6 +2564,77 @@ describe('restoreSnapshot manifest verification', () => {
expect(await finishRestore({ dryRun: true })).not.toHaveProperty('ledgerGap');
});
+ // Snapshots from before migrations moved out of data/ (May 2026) carry the
+ // ledger at migrations/.applied.json. rsync lands it beside the live
+ // migrations.applied.json, which the runner then keeps, so without adoption
+ // a full restore would re-run nothing over the restored records.
+ describe('snapshot with the pre-May-2026 ledger location', () => {
+ const liveLegacyLedgerPath = () => joinPath(PATHS.data, 'migrations', '.applied.json');
+ const parkedLedgers = async () => (await realFs.readdir(PATHS.data)).filter(name => name.startsWith('migrations.applied.json.pre-restore-'));
+
+ afterEach(async () => {
+ await realFs.rm(joinPath(PATHS.data, 'migrations'), { recursive: true, force: true });
+ for (const name of await parkedLedgers()) await realFs.rm(joinPath(PATHS.data, name), { force: true });
+ });
+
+ async function seedLegacySnapshot({ alsoCurrent = false } = {}) {
+ const manifest = { 'migrations/.applied.json': await writeSnapshotFile('migrations/.applied.json', JSON.stringify(['001-example.js'])) };
+ if (alsoCurrent) manifest['migrations.applied.json'] = await writeSnapshotFile('migrations.applied.json', JSON.stringify(['001-example.js']));
+ await writeManifest(manifest);
+ }
+
+ it('announces the adoption in a preview without touching the live ledger', async () => {
+ await seedLegacySnapshot();
+ await realFs.writeFile(liveLedgerPath(), JSON.stringify(['001-example.js', '359-example.js']));
+
+ await expect(finishRestore({ dryRun: true })).resolves.toMatchObject({ restoredLegacyLedger: { status: 'pending', parkedAs: null } });
+ expect(JSON.parse(await realFs.readFile(liveLedgerPath(), 'utf8'))).toEqual(['001-example.js', '359-example.js']);
+ });
+
+ it('installs the restored legacy ledger as the live one and parks the previous ledger', async () => {
+ await seedLegacySnapshot();
+ await realFs.writeFile(liveLedgerPath(), JSON.stringify(['001-example.js', '359-example.js']));
+ // rsync is faked, so stand in for its transfer of the snapshot ledger.
+ await realFs.mkdir(joinPath(PATHS.data, 'migrations'), { recursive: true });
+ await realFs.writeFile(liveLegacyLedgerPath(), JSON.stringify(['001-example.js']));
+
+ const result = await finishRestore({ dryRun: false });
+
+ expect(result.restoredLegacyLedger).toEqual({ status: 'adopted', parkedAs: expect.stringMatching(/^migrations\.applied\.json\.pre-restore-/) });
+ expect(JSON.parse(await realFs.readFile(liveLedgerPath(), 'utf8'))).toEqual(['001-example.js']);
+ expect(JSON.parse(await realFs.readFile(joinPath(PATHS.data, result.restoredLegacyLedger.parkedAs), 'utf8'))).toEqual(['001-example.js', '359-example.js']);
+ expect(existsSync(liveLegacyLedgerPath())).toBe(false);
+ });
+
+ it('adopts the ledger on an install that had none, parking nothing', async () => {
+ await seedLegacySnapshot();
+ await realFs.mkdir(joinPath(PATHS.data, 'migrations'), { recursive: true });
+ await realFs.writeFile(liveLegacyLedgerPath(), JSON.stringify(['001-example.js']));
+
+ await expect(finishRestore({ dryRun: false })).resolves.toMatchObject({ restoredLegacyLedger: { status: 'adopted', parkedAs: null } });
+ expect(JSON.parse(await realFs.readFile(liveLedgerPath(), 'utf8'))).toEqual(['001-example.js']);
+ expect(await parkedLedgers()).toEqual([]);
+ });
+
+ it('leaves a snapshot that also carries a current-path ledger to rsync', async () => {
+ await seedLegacySnapshot({ alsoCurrent: true });
+ await realFs.writeFile(liveLedgerPath(), JSON.stringify(['001-example.js', '359-example.js']));
+
+ const result = await finishRestore({ dryRun: false });
+ expect(result).not.toHaveProperty('restoredLegacyLedger');
+ expect(await parkedLedgers()).toEqual([]);
+ });
+
+ it('keeps the live ledger on a folder restore and reads the legacy ledger for the gap', async () => {
+ await seedLegacySnapshot();
+ await realFs.writeFile(liveLedgerPath(), JSON.stringify(['001-example.js', '359-example.js']));
+
+ const result = await finishRestore({ dryRun: true, subdirFilter: 'cos' });
+ expect(result).not.toHaveProperty('restoredLegacyLedger');
+ expect(result.ledgerGap).toEqual({ count: 1, names: ['359-example.js'] });
+ });
+ });
+
it('converts a restored legacy quota-burn plan to task references, once', async () => {
await seedSnapshot();
// rsync is faked, so stand in for its transfer of the snapshot plan.