summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-03-30 09:17:26 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2024-03-30 09:17:26 +0100
commit9006aef87c1dd042dd140f71a09279e95f803227 (patch)
tree52d7d365d4b15a8ee51013102ca2537ecb5d10f1 /src
parentf75555508819b02df06fb79c20d7ad23be8ecda6 (diff)
only copy non existing
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 12c920d..f390f31 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,12 +7,16 @@ use walkdir::WalkDir;
async fn copy(from: String, to: String) -> std::io::Result<()> {
let from_path = std::path::Path::new(&from);
let to_path = std::path::Path::new(&to);
- if from_path.is_dir() {
- std::fs::create_dir_all(to)?;
- } else if from_path.is_file() {
- std::fs::create_dir_all(to_path.parent().unwrap())?;
- std::fs::copy(from, to)?;
+
+ if !to_path.exists() {
+ if from_path.is_dir() {
+ std::fs::create_dir_all(to)?;
+ } else if from_path.is_file() {
+ std::fs::create_dir_all(to_path.parent().unwrap())?;
+ std::fs::copy(from, to)?;
+ }
}
+
Ok(())
}