mirror of
https://github.com/lune-org/lune.git
synced 2025-04-08 04:20:54 +01:00
Check that target exists before trying removing it
This commit is contained in:
parent
507d88e63e
commit
b75cc2a90d
1 changed files with 7 additions and 2 deletions
|
@ -137,8 +137,13 @@ pub async fn copy(
|
||||||
} else if is_dir {
|
} else if is_dir {
|
||||||
let contents = get_contents_at(source.to_path_buf(), options).await?;
|
let contents = get_contents_at(source.to_path_buf(), options).await?;
|
||||||
|
|
||||||
if options.overwrite {
|
if options.overwrite && target.exists() {
|
||||||
fs::remove_dir_all(target).await?;
|
let metadata = fs::metadata(target).await?;
|
||||||
|
if metadata.is_file() {
|
||||||
|
fs::remove_file(target).await?;
|
||||||
|
} else if metadata.is_dir() {
|
||||||
|
fs::remove_dir_all(target).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUTURE: Write dirs / files concurrently
|
// FUTURE: Write dirs / files concurrently
|
||||||
|
|
Loading…
Add table
Reference in a new issue