/** * zstd delta backend. * * Modified files: zstd --patch-from=prev new -o out.zst * New files: zstd new -o out.zst (no base, just compress) * Deleted files: no delta file, manifest entry only */ import { run } from '../spawn.js'; export const name = 'zstd'; export const ext = '.zst'; /** * Create a delta from prevFile to newFile, output to outFile. * If prevFile is null, newFile is new — compress without a base. */ export async function createDelta(prevFile, newFile, outFile, { dryRun } = {}) { if (prevFile) { await run('zstd', ['--patch-from', prevFile, newFile, '-o', outFile, '-f'], { dryRun }); } else { await run('zstd', [newFile, '-o', outFile, '-f'], { dryRun }); } } /** * Apply a delta on top of prevFile to produce outFile. * If prevFile is null, the delta is a plain compressed file. */ export async function applyDelta(prevFile, deltaFile, outFile, { dryRun } = {}) { if (prevFile) { await run('zstd', ['-d', '--patch-from', prevFile, deltaFile, '-o', outFile, '-f'], { dryRun }); } else { await run('zstd', ['-d', deltaFile, '-o', outFile, '-f'], { dryRun }); } }