Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(proxy): the encoder lets go of its file before the copy is moved into place

marcinx98x543443a8bf55
diff --git a/src/crates/concat-host/src/enhance.rs b/src/crates/concat-host/src/enhance.rs
index bf254778..d8330fe3 100644
--- a/src/crates/concat-host/src/enhance.rs
+++ b/src/crates/concat-host/src/enhance.rs
@@ -260,6 +260,10 @@ fn footage(
}
encoder.finish().map_err(|error| error.to_string())
})();
+ // Windows will not rename or delete a file something still holds open,
+ // and a finished encoder keeps its output open until it is dropped.
+ drop(encoder);
+ drop(decoder);
if let Err(error) = encoded {
let _ = std::fs::remove_file(&partial_video);
return Err(error);
diff --git a/src/crates/concat-host/src/proxy.rs b/src/crates/concat-host/src/proxy.rs
index d6781add..2b5f587e 100644
--- a/src/crates/concat-host/src/proxy.rs
+++ b/src/crates/concat-host/src/proxy.rs
@@ -253,6 +253,10 @@ pub fn write(
}
encoder.finish().map_err(|error| error.to_string())
})();
+ // Windows will not rename or delete a file something still holds open,
+ // and a finished encoder keeps its output open until it is dropped.
+ drop(encoder);
+ drop(decoder);
match result {
Ok(()) => std::fs::rename(&partial, target)
.map_err(|error| format!("{}: {error}", target.display())),