Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

fix: use async file I/O in async MCP screenshot handler (SonarCloud rust:S7493) (#2724)

Dylan M. Taylor3325caab6ae1
diff --git a/crates/automation/Cargo.toml b/crates/automation/Cargo.toml
index 14b090e7d..3a2e4b965 100644
--- a/crates/automation/Cargo.toml
+++ b/crates/automation/Cargo.toml
@@ -16,7 +16,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
rmcp = { version = "3.5", default-features = false, features = ["server", "macros", "transport-io"] }
-tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "sync", "net", "io-util", "time"] }
+tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "sync", "net", "io-util", "time", "fs"] }
base64 = "0.22"
schemars = "1"
image = { version = "0.25", default-features = false, features = ["png"] }
diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs
index fad4e4192..3a9cb8e1c 100644
--- a/crates/automation/src/server.rs
+++ b/crates/automation/src/server.rs
@@ -568,11 +568,11 @@ impl FilmcraftMcp {
if let Err(e) = b.call("ui.screenshot", json!({"path": path.to_string_lossy(), "panel": panel})).await {
return Ok(fail(e));
}
- let bytes = match std::fs::read(&path) {
+ let bytes = match tokio::fs::read(&path).await {
Ok(b) => b,
Err(e) => return Ok(fail(format!("screenshot: {e}"))),
};
- let _ = std::fs::remove_file(&path);
+ let _ = tokio::fs::remove_file(&path).await;
let bytes = match image::load_from_memory(&bytes) {
Ok(img) => {
let rgba = img.to_rgba8();