fix: preserve archive restores after pruning

This commit is contained in:
2026-05-08 16:24:45 +00:00
parent 904318531a
commit 56a5fa27f4
5 changed files with 1945 additions and 4100 deletions
+13
View File
@@ -185,6 +185,19 @@ tap.test('should prune with keepLast=1', async () => {
// Verify only 1 snapshot remains
const snapshots = await repo.listSnapshots();
expect(snapshots.length).toEqual(1);
// The remaining snapshot must still restore after partial-pack GC rewrites chunks.
const restoreStream = await repo.restore(snapshots[0].id, { item: 'config.tar' });
const chunks: Buffer[] = [];
await new Promise<void>((resolve, reject) => {
restoreStream.on('data', (chunk: Buffer) => chunks.push(chunk));
restoreStream.on('end', resolve);
restoreStream.on('error', reject);
});
const restored = Buffer.concat(chunks);
const expected = Buffer.alloc(32 * 1024, 'item-two-data');
expect(restored.equals(expected)).toBeTrue();
});
// ==================== Close ====================