Do not copy a file if it already exists.
This commit is contained in:
parent
59ee13345e
commit
4a0cbf3ba5
@ -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(())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user