fix(storage): abort truncated rclone uploads and strengthen stderr test

This commit is contained in:
Charles GTE
2026-09-10 07:58:01 +02:00
parent b222b13934
commit ea356ed54f
2 changed files with 18 additions and 2 deletions
@@ -133,7 +133,17 @@ pub async fn rcat(config_path: &Path, target: &str, mut stream: RcloneStream) ->
while let Some(chunk) = stream.next().await {
// A stream error is ours, not rclone's — report it directly.
let chunk = chunk.context("backup stream failed")?;
let chunk = match chunk {
Ok(c) => c,
Err(e) => {
// Returning here would drop stdin and hand rclone an EOF, which it
// treats as a complete stream — finalizing a truncated object that
// looks like a good backup. Kill it instead.
let _ = child.start_kill();
let _ = child.wait().await;
return Err(e).context("backup stream failed");
}
};
// A write error means rclone already exited. Stop pumping and let the
// exit status below produce the real reason; surfacing the broken-pipe
+7 -1
View File
@@ -251,5 +251,11 @@ async fn rcat_reports_rclone_stderr_when_the_remote_is_unreachable() {
msg.contains("rclone rcat failed"),
"the broken stdin pipe must not mask rclone's own error: {msg}"
);
assert!(!msg.trim().ends_with("failed"), "rclone stderr must be included: {msg}");
let (_, stderr_part) = msg
.rsplit_once(": ")
.expect("bail message must carry rclone stderr after the exit status");
assert!(
!stderr_part.trim().is_empty(),
"rclone stderr must be included: {msg}"
);
}