Skip to content

Commit daf6f51

Browse files
committed
docs(redo): qualify the comment on restoring after a failed replace
Review follow-up on #231. The comment in `apply_replace_content` said that putting the overwritten bytes back "does not need the space or quota the failed write ran out of". That holds on a filesystem that overwrites in place. On a copy-on-write filesystem an overwrite can need new space, and an I/O error can fail any write. The comment now says so and points at the error reported when the restore fails. Comment only; no behaviour change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J4QvDiC97Fg2LvDpuFCz95
1 parent 94be017 commit daf6f51

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎impl/rust-cli/src/commands.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,12 @@ fn apply_replace_content(
14551455
// Open without `create`, so the write lands in the file that was read,
14561456
// and without `truncate`: the new content is written over the old and the
14571457
// file is cut to length afterwards. The old bytes are then still in place
1458-
// if the write fails, and putting them back never grows the file, so it
1459-
// does not need the space or quota the failed write ran out of.
1458+
// if the write fails, and putting them back never grows the file. On a
1459+
// filesystem that overwrites in place, that needs none of the space or
1460+
// quota the failed write ran out of. It is not a guarantee: a
1461+
// copy-on-write filesystem can need new space even for an overwrite, and
1462+
// an I/O error can fail any write, which is why a failed restore is
1463+
// reported below.
14601464
use std::io::{Seek, SeekFrom};
14611465
let mut file = fs::OpenOptions::new()
14621466
.write(true)

0 commit comments

Comments
 (0)