Fix archives panicking when asked to overwrite file

This commit is contained in:
Spyros Roum 2021-11-02 13:34:38 +02:00
parent 547b8c91e5
commit 7f5ff0faf1
2 changed files with 4 additions and 4 deletions

View File

@ -35,10 +35,10 @@ pub fn unpack_archive(
}
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?
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)?;

View File

@ -42,10 +42,10 @@ where
}
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?
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);