fix(store): truncating an append-only log goes through a write handle on Windows (P11c)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s

std's append(true) opens without FILE_WRITE_DATA, so SetEndOfFile on that
handle is refused (PermissionDenied) on Windows: the torn-line cut on open
(chain::tests::an_unfinished_last_line_is_cut_away_on_open) and the
roll-back of a failed append (chain and journal) could not truncate. Not a
rename/share-delete problem: std already opens with all three sharing
flags. chain::truncate cuts through a short-lived write handle on Windows
and the handle itself elsewhere; the journal's roll-back uses it too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
swaitsandClaude Fable 5.1 committed 2026-10-30 07:49:03 -06:00
1 parent 73804ac8ba
commit b96735da01
3 files changed
+33 -6

No files matched your search

+1 -2
View File
@@ -228,8 +228,7 @@ impl JournalWriter {
.and_then(|()| self.file.write_all(b"\n"))
.and_then(|()| self.file.sync_all());
if let Err(e) = written {
let _ = self.file.set_len(before);
let _ = self.file.sync_all();
let _ = crate::chain::truncate(&self.file, &self.path, before);
return Err(e.into());
}
self.prev_hash = sha256_hex(bytes.as_bytes());