diff --git a/src/context/dependency.rs b/src/context/dependency.rs index aa4aab7..e79063f 100644 --- a/src/context/dependency.rs +++ b/src/context/dependency.rs @@ -27,8 +27,17 @@ impl Dependency { .ok_or("Output file should have a containing directory.")?, ) .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(()) } }