mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Fix archives panicking when asked to overwrite file
This commit is contained in:
parent
547b8c91e5
commit
7f5ff0faf1
@ -35,10 +35,10 @@ pub fn unpack_archive(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file_path.is_dir() {
|
if file_path.is_dir() {
|
||||||
// We can't just use `fs::File::create(&file_path)` because it would return io::ErrorKind::IsADirectory
|
|
||||||
// ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
|
// ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
|
||||||
fs::remove_dir_all(&file_path)?;
|
fs::remove_dir_all(&file_path)?;
|
||||||
fs::File::create(&file_path)?;
|
} else if file_path.is_file() {
|
||||||
|
fs::remove_file(&file_path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.unpack_in(output_folder)?;
|
file.unpack_in(output_folder)?;
|
||||||
|
@ -42,10 +42,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file_path.is_dir() {
|
if file_path.is_dir() {
|
||||||
// We can't just use `fs::File::create(&file_path)` because it would return io::ErrorKind::IsADirectory
|
|
||||||
// ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
|
// ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
|
||||||
fs::remove_dir_all(&file_path)?;
|
fs::remove_dir_all(&file_path)?;
|
||||||
fs::File::create(&file_path)?;
|
} else if file_path.is_file() {
|
||||||
|
fs::remove_file(&file_path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_for_comments(&file);
|
check_for_comments(&file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user