diff --git a/src/archive/tar.rs b/src/archive/tar.rs index a778728..c71cdbb 100644 --- a/src/archive/tar.rs +++ b/src/archive/tar.rs @@ -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)?; diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 83de647..9085129 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -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);