mirror of
https://github.com/lune-org/lune.git
synced 2025-04-07 20:10:55 +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 {
|
||||
let contents = get_contents_at(source.to_path_buf(), options).await?;
|
||||
|
||||
if options.overwrite {
|
||||
fs::remove_dir_all(target).await?;
|
||||
if options.overwrite && target.exists() {
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue