ba25a6819e6f
say how to finish a restore the moment it stops part way, not to retry it (3.0.43, codex review pending)
- time
- 2026-09-24 15:08 UTC · 2 weeks ago
- machine
- koh2
- agent
- claude-opus-5-5
- session
- koh 3 reliability campaign
- parent
- 4d41f88e04ed
↓ koh-ba25a681.tar.gzatlas at this save
files changed4 files
VERSION+1 −1src/snapshot/restore.v+16 −5tests/cli_test.v+3 −1v.mod+1 −1src/snapshot/restore.v+16 −5
@@ -45,7 +45,21 @@4545 // rather than half-written files.4646 pub fn restore_files(store &storage.Store, root string, ig Ignore, target []FileEntry, remove []string) !RestoreReport {4747 // Peek writes elsewhere; only the repo's own tree carries the mark.48- marks := root == store.root48+ in_repo := root == store.root49+ report := write_tree(store, root, ig, target, remove) or {50+ // The save is recorded by now, so the way on is to finish, not retry.51+ if in_repo {52+ return error('${err.msg()} — the restore stopped part way; fix that, then run koh revert to finish it')53+ }54+ return err55+ }56+ if in_repo {57+ clear_restore_mark(store)!58+ }59+ return report60+}61+62+fn write_tree(store &storage.Store, root string, ig Ignore, target []FileEntry, remove []string) !RestoreReport {4963 mut wanted := map[string]bool{}5064 for entry in target {5165 wanted[entry.path] = true@@ -67,7 +81,7 @@6781 full := os.join_path(root, entry.path)6882 if os.is_dir(full) {6983 os.rmdir(full) or {70- return error('${entry.path} is a folder of ignored files where a saved file belongs — move it, then run the command again')84+ return error('${entry.path} is a folder of ignored files where a saved file belongs — move it')7185 }7286 }7387 }@@ -85,9 +99,6 @@8599 data := store.get_object(entry.hash)!86100 write_file(os.join_path(root, entry.path), data, entry.executable)!87101 written++88- }89- if marks {90- clear_restore_mark(store)!91102 }92103 return RestoreReport{93104 written: writtentests/cli_test.v+3 −1
@@ -236,7 +236,9 @@236236 // a.txt is written, then the read-only folder stops the restore: the237237 // tree is genuinely half one save and half the other.238238 os.chmod(os.join_path(dir, 'zz'), 0o555)!239- assert run(dir, 'undo', '--yes').code == 1239+ stopped := run(dir, 'undo', '--yes')240+ assert stopped.code == 1241+ assert stopped.err.contains('koh revert')240242 assert os.read_file(os.join_path(dir, 'a.txt'))! == 'v1\n'241243 assert os.read_file(os.join_path(dir, 'zz/f'))! == 'v2\n'242244 // Even a status that cannot read the tree says what happened.v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.42'3+ version: '3.0.43'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }