You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Backup before a file write: fail when the source changes during the copy #1737
A backup made before a confirmed file write is a consistent copy of one file version, even if the file is replaced while it is being copied.
Context
Follow-up of #1714 (PR #1728): copy_to_backup_inner (crates/app-logic/src/orchestration/remote_files.rs:370-413) copies via SftpSession::read_range, which opens the file anew for every 256 KiB chunk (crates/ssh-transport/src/sftp.rs). If the file is atomically replaced (rename over it) mid-copy, chunks come from different files and the backup is a mix, while the recorded SHA-256 describes that mix.
Requirements
After the copy, stat the source again; when its size or modification time differs from the values taken before the copy, the backup fails: the partial/mixed backup is removed best-effort and the write fails before the target is touched.
No change for files that stay unchanged.
Acceptance Criteria
Mock: a source whose mtime (or size) changes during the copy makes the write fail, the backup is removed, the target is untouched.
An unchanged multi-chunk file is backed up byte-for-byte as before.
A failing second stat fails the backup safely (no backup left).
Relevant automated tests pass
Technical Notes
Chosen over a single open handle because the trait has no handle-based read (adding one would change every SftpSession implementation and mock). Alternative for the coder: a new read_handle API. Spec 0020 §4.2.4: one sentence that a file changing during the backup fails the write.
Needs maintainer: The issue waits for #1733, but "blocked by" could not be set. Set it on the issue (Relationships), then remove needs-maintainer: The code this issue changes (copy_to_backup_inner, chunked read_range backup from #1714/PR #1728) exists only on release/0.8.0; develop still has the old read_file-based write_via_sftp_with_backup. Waiting for the back-merge of release/0.8.0 into develop (#1733).
Activity
smart-ssh-coder commentedon Dec 4, 2026
Needs maintainer: The issue waits for #1733, but "blocked by" could not be set. Set it on the issue (Relationships), then remove needs-maintainer: The code this issue changes (copy_to_backup_inner, chunked read_range backup from #1714/PR #1728) exists only on release/0.8.0; develop still has the old read_file-based write_via_sftp_with_backup. Waiting for the back-merge of release/0.8.0 into develop (#1733).