Copies a plan, taking every backup BEFORE the first byte is written.
The ordering is the rule, not an implementation detail. Backing up each file just before
overwriting it leaves a failure part-way through with half a tree replaced and half of it
unbacked, which is strictly worse than either finishing or refusing. So: back everything up,
verify each backup by digest against the file it came from, and only then write.
Lifted from what drupflare/worker does by hand -- bake-pack.ts snapshots site.sqlite before
its first write, hydrate.ts verifies every byte against a manifest before it lands, and
backup-cdn.ts refuses to replace content that differs without an explicit flag. All three are
the same rule and none of them was reusable.
Copies a plan, taking every backup BEFORE the first byte is written.
The ordering is the rule, not an implementation detail. Backing up each file just before overwriting it leaves a failure part-way through with half a tree replaced and half of it unbacked, which is strictly worse than either finishing or refusing. So: back everything up, verify each backup by digest against the file it came from, and only then write.
Lifted from what
drupflare/workerdoes by hand --bake-pack.tssnapshotssite.sqlitebefore its first write,hydrate.tsverifies every byte against a manifest before it lands, andbackup-cdn.tsrefuses to replace content that differs without an explicit flag. All three are the same rule and none of them was reusable.