minor tweaks

This commit is contained in:
João M. Bezerra 2022-10-11 21:24:04 -03:00
parent 71893aafeb
commit a2c91c4248
3 changed files with 12 additions and 5 deletions

View File

@ -9,7 +9,6 @@ use std::{
};
use fs_err as fs;
use tar;
use crate::{
error::FinalError,
@ -40,7 +39,12 @@ pub fn unpack_archive(
// spoken text for users using screen readers, braille displays
// and so on
info!(@display_handle, inaccessible, "{:?} extracted. ({})", utils::strip_cur_dir(&output_folder.join(file.path()?)), Bytes::new(file.size()));
info!(
@display_handle,
inaccessible,
"{:?} extracted. ({})",
utils::strip_cur_dir(&output_folder.join(file.path()?)), Bytes::new(file.size())
);
files_unpacked.push(file_path);
}

View File

@ -68,7 +68,12 @@ where
let file_path = strip_cur_dir(file_path.as_path());
// same reason is in _is_dir: long, often not needed text
info!(@display_handle, inaccessible, "{:?} extracted. ({})", file_path.display(), Bytes::new(file.size()));
info!(
@display_handle,
inaccessible,
"{:?} extracted. ({})",
file_path.display(), Bytes::new(file.size())
);
let mut output_file = fs::File::create(file_path)?;
io::copy(&mut file, &mut output_file)?;

View File

@ -60,8 +60,6 @@ pub fn create_or_ask_overwrite(path: &Path, question_policy: QuestionPolicy) ->
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {
if user_wants_to_overwrite(path, question_policy)? {
if path.is_dir() {
// We can't just use `fs::File::create(&path)` because it would return io::ErrorKind::IsADirectory
// ToDo: Maybe we should emphasise that `path` is a directory and everything inside it will be gone?
fs::remove_dir_all(path)?;
}
Ok(Some(fs::File::create(path)?))