fix(desktop): clean staged avconvert inputs

Remove partial staged sources when a fallback copy fails, and honor
cancellation before starting AVFoundation conversion.

Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
Wes
2026-08-21 18:32:57 -06:00
parent 6fb63e9cc9
commit ec68dccf33

View File

@@ -478,7 +478,10 @@ fn prepare_avconvert_source(
));
if std::fs::hard_link(source, &staged).is_err() {
std::fs::copy(source, &staged)
.map_err(|error| format!("failed to stage video for conversion: {error}"))?;
.map_err(|error| format!("failed to stage video for conversion: {error}"))
.inspect_err(|_| {
let _ = std::fs::remove_file(&staged);
})?;
}
Ok((staged, true))
}
@@ -495,6 +498,12 @@ fn transcode_with_avconvert(
) -> Result<Vec<u8>, String> {
let output = std::env::temp_dir().join(format!("buzz-avconvert-{}.mp4", uuid::Uuid::new_v4()));
let (prepared_source, remove_prepared_source) = prepare_avconvert_source(source)?;
if cancellation.is_some_and(CancellationToken::is_cancelled) {
if remove_prepared_source {
let _ = std::fs::remove_file(&prepared_source);
}
return Err("upload cancelled".to_string());
}
let result = (|| {
let mut command = std::process::Command::new("/usr/bin/avconvert");