fix(store): truncating an append-only log goes through a write handle on Windows (P11c)
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:
1 parent
73804ac8ba
commit
b96735da01
3 files changed
+33
-6
No files matched your search
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user