diff --git a/src/archive/tar.rs b/src/archive/tar.rs index 5aadb46..a778728 100644 --- a/src/archive/tar.rs +++ b/src/archive/tar.rs @@ -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())); diff --git a/src/archive/zip.rs b/src/archive/zip.rs index b62afd7..83de647 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -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('/') {