put: check the SFTP close status after uploads
ssh2::File's Drop discards the close-handshake error ('too late to
recover'), so a quota or server-side abort surfacing in the final ACKs
was recorded as a successful upload of a truncated file. Close upload
handles explicitly and propagate the error; also applies to the ssh
context driver's write_file and upload_recursive, which had the same
silent-drop issue.
This commit is contained in:
@@ -433,6 +433,16 @@ pub fn upload_file(
|
||||
bar.inc(n as u64);
|
||||
}
|
||||
|
||||
// Close explicitly: quota-exceeded and similar failures only surface in
|
||||
// the final ACKs and the close handshake, and the `Drop` impl of
|
||||
// `ssh2::File` discards that error ("too late to recover"), recording a
|
||||
// truncated remote file as a successful upload. `ssh2::File::write` is
|
||||
// unbuffered (`Write::flush` is a documented no-op) and `close`
|
||||
// finalizes the pending writes server-side, so no flush is needed.
|
||||
remote_file
|
||||
.close()
|
||||
.map_err(|e| format!("failed to close remote file '{remote}' after upload: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user