f7de384191a7
let the remote connection test recover from a leftover probe (3.0.14)
- time
- 2026-09-23 22:07 UTC · 2 weeks ago
- machine
- koh2
- agent
- claude-opus-5-5
- session
- koh 3 review fixes
- parent
- 351a8a04769d
↓ koh-f7de3841.tar.gzatlas at this save
files changed4 files
VERSION+1 −1src/remote/folder_test.v+6 −0src/remote/remote.v+9 −2v.mod+1 −1src/remote/folder_test.v+6 −0
@@ -96,4 +96,10 @@9696 mut backend := new_folder(base)!9797 check(mut backend)!9898 assert !backend.get(probe_key)!.found99+100+ // A check interrupted after its first write leaves the probe behind; the101+ // next check must not mistake it for a remote that refuses writes.102+ backend.put_if_absent(probe_key, 'left over'.bytes())!103+ check(mut backend)!104+ assert !backend.get(probe_key)!.found99105 }src/remote/remote.v+9 −2
@@ -35,16 +35,23 @@3535 // delete it. A backend that cannot do that cannot keep two machines honest.3636 pub fn check(mut backend Backend) ! {3737 payload := 'koh probe'.bytes()38+ // The probe is Koh's own key; one left by an interrupted check would make39+ // the first write below look refused.40+ backend.delete(probe_key)!3841 if !backend.put_if_absent(probe_key, payload)! {39- return error('the remote already has a probe object — it is not empty, or it cannot refuse a second write')42+ return error('the remote refused to store a new object')4043 }44+ defer {45+ // Also on the early returns below; deleting twice is harmless.46+ backend.delete(probe_key) or {}47+ }4148 if backend.put_if_absent(probe_key, payload)! {42- backend.delete(probe_key)!4349 return error('the remote overwrote an existing object — conditional writes are not working')4450 }4551 probe := backend.get(probe_key)!4652 if !probe.found || probe.body != payload {4753 return error('the remote did not give back what was written')4854 }55+ // Strip needs delete, so a remote that cannot delete fails here.4956 backend.delete(probe_key)!5057 }v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.13'3+ version: '3.0.14'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }