Do not copy a file if it already exists.
Some checks failed
format Build format has started
rust-test Build rust-test has started
clippy Build clippy has failed

This commit is contained in:
Tom Alexander 2025-02-08 20:06:09 -05:00
parent 59ee13345e
commit 4a0cbf3ba5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -27,8 +27,17 @@ impl Dependency {
.ok_or("Output file should have a containing directory.")?, .ok_or("Output file should have a containing directory.")?,
) )
.await?; .await?;
// TODO: If file already exists, either error out or compare hash to avoid duplicate write.
tokio::fs::copy(absolute_path, path_to_output).await?; if tokio::fs::metadata(&path_to_output).await.is_ok() {
// TODO: compare hash and error out if they do not match.
println!(
"Not copying {} to {} because the output file already exists.",
absolute_path.display(),
path_to_output.display()
);
} else {
tokio::fs::copy(absolute_path, path_to_output).await?;
}
Ok(()) Ok(())
} }
} }