Ask to overwrite dirs when decompressing archives

This commit is contained in:
Spyros Roum 2021-11-02 12:38:10 +02:00
parent 70c81ed8a4
commit 8ef1b25b12
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,13 @@ pub fn unpack_archive(
continue;
}
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)?;
}
file.unpack_in(output_folder)?;
info!("{:?} extracted. ({})", output_folder.join(file.path()?), Bytes::new(file.size()));

View File

@ -41,6 +41,13 @@ where
continue;
}
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)?;
}
check_for_comments(&file);
match (&*file.name()).ends_with('/') {