fix(store): a backup is proven after it is written and repaired when a piece is damaged; a drill passes only on the newest backup
A backup that restores old or wrong books while reporting good is the worst defect the product can have. A piece already in the destination was taken as the piece (its name is its hash), the manifest built on the newest backup whose pieces were the right length, no proof ran after a backup, and the drill fell back to older manifests and recorded ok with the older head. - the manifest just written is read back and proven before the backup is recorded good: every journal and access segment re-hashed, the chain replayed to its head, vault and keys present, the index, and the stored files this backup added plus a rotating sixteenth of the others (every stored file is re-read within 16 manifest numbers; the drill re-hashes all) - a piece found damaged is written again under a generation suffix beside the damaged file (never touched), a new manifest names it, and the reader accepts any generation of a piece whose contents hash right - the drill passes only on the newest manifest, and only when it reaches the head of the last backup recorded good; an older whole backup is a failure that says so with its date - no consolidation: a manifest names the one before it and only what is new (a chain of 64, each link proven by the hash its successor holds) - restore and drill read newest first and stop at the first that proves - live books that are the beginning of the destination's longer history are ahead; any other mismatch is diverged or other books - a new set can begin beside the old (.2), never touching it; set folders carry a fixed prefix so no book id is a reserved name on Windows - no hard link is never a reason to replace: only errors that mean the disk makes no links fall back, to a move that refuses to replace - sealed pieces are sharded by two digits; header settings are capped at 4x and bound into the sealed check; find derives one key per distinct setting - vault scratch files are never backed up as records - files a sync service has not downloaded read as not downloaded yet Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
49459c9f6a
commit
6a8dc6c88b
14 files changed
+2116
-439
No files matched your search
@@ -2697,7 +2697,7 @@ fn a_backup_is_restored_from_the_command_line() {
|
||||
);
|
||||
assert_eq!(s["targets"][0]["last_error"], Value::Null, "{s}");
|
||||
let head = s["head_seq"].as_u64().unwrap();
|
||||
let backup = disk.join("acme");
|
||||
let backup = disk.join("wanderbooks-acme");
|
||||
let backup = backup.to_str().unwrap();
|
||||
// Previewed, and not done without a yes.
|
||||
let out = home.books(&["restore", backup, "--id", "copy"]);
|
||||
@@ -2717,7 +2717,7 @@ fn a_backup_is_restored_from_the_command_line() {
|
||||
// A folder named otherwise: restored as the books it holds, by default
|
||||
// (here: over those, refused), said.
|
||||
let renamed = home.dir.path().join("fernhill-backup");
|
||||
copy_folder(&disk.join("acme"), &renamed);
|
||||
copy_folder(&disk.join("wanderbooks-acme"), &renamed);
|
||||
let out = home.books(&["restore", renamed.to_str().unwrap(), "--yes"]);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("already books called \"acme\""),
|
||||
@@ -2925,9 +2925,9 @@ fn books_are_backed_up_now_from_the_command_line() {
|
||||
String::from_utf8_lossy(&out.stdout).contains("Backed up to the backup folder"),
|
||||
"{out:?}"
|
||||
);
|
||||
assert!(disk.join("acme").join("manifests").is_dir());
|
||||
assert!(disk.join("wanderbooks-acme").join("manifests").is_dir());
|
||||
// A folder gone since: said, and --new-disk begins it again.
|
||||
std::fs::rename(disk.join("acme"), home.dir.path().join("away")).unwrap();
|
||||
std::fs::rename(disk.join("wanderbooks-acme"), home.dir.path().join("away")).unwrap();
|
||||
let out = home.books(&["back-up", "acme"]);
|
||||
assert_eq!(out.status.code(), Some(1), "{out:?}");
|
||||
assert!(
|
||||
@@ -2936,7 +2936,7 @@ fn books_are_backed_up_now_from_the_command_line() {
|
||||
);
|
||||
let out = home.books(&["back-up", "acme", "--new-disk"]);
|
||||
assert!(out.status.success(), "{out:?}");
|
||||
assert!(disk.join("acme").join("manifests").is_dir());
|
||||
assert!(disk.join("wanderbooks-acme").join("manifests").is_dir());
|
||||
a.end();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user