Clippy lints

This commit is contained in:
João M. Bezerra 2021-04-04 01:58:22 -03:00
parent c83b38a874
commit 5b37a117f1
4 changed files with 20 additions and 20 deletions

View File

@ -35,12 +35,12 @@ impl TarDecompressor {
let mut file = file?; let mut file = file?;
let file_path = PathBuf::from(into).join(file.path()?); let file_path = PathBuf::from(into).join(file.path()?);
if file_path.exists() { if file_path.exists()
if !utils::permission_for_overwriting(&file_path, flags, &confirm)? { && !utils::permission_for_overwriting(&file_path, flags, &confirm)?
{
// The user does not want to overwrite the file // The user does not want to overwrite the file
continue; continue;
} }
}
file.unpack_in(into)?; file.unpack_in(into)?;

View File

@ -11,7 +11,7 @@ use super::decompressor::{DecompressionResult, Decompressor};
use crate::{cli::Flags, dialogs::Confirmation, file::File, utils}; use crate::{cli::Flags, dialogs::Confirmation, file::File, utils};
#[cfg(unix)] #[cfg(unix)]
fn __unix_set_permissions(file_path: &PathBuf, file: &ZipFile) { fn __unix_set_permissions(file_path: &Path, file: &ZipFile) {
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
if let Some(mode) = file.unix_mode() { if let Some(mode) = file.unix_mode() {
@ -52,12 +52,12 @@ impl ZipDecompressor {
}; };
let file_path = into.join(file_path); let file_path = into.join(file_path);
if file_path.exists() { if file_path.exists()
if !utils::permission_for_overwriting(&file_path, flags, &confirm)? { && !utils::permission_for_overwriting(&file_path, flags, &confirm)?
{
// The user does not want to overwrite the file // The user does not want to overwrite the file
continue; continue;
} }
}
Self::check_for_comments(&file); Self::check_for_comments(&file);

View File

@ -162,12 +162,12 @@ impl Evaluator {
// TODO: use -y and -n here // TODO: use -y and -n here
let output_path = output.path.clone(); let output_path = output.path.clone();
if output_path.exists() { if output_path.exists()
if !utils::permission_for_overwriting(&output_path, flags, &confirm)? { && !utils::permission_for_overwriting(&output_path, flags, &confirm)?
{
// The user does not want to overwrite the file // The user does not want to overwrite the file
return Ok(()); return Ok(());
} }
}
let bytes = match first_compressor { let bytes = match first_compressor {
Some(first_compressor) => { Some(first_compressor) => {

View File

@ -59,7 +59,7 @@ pub(crate) fn get_destination_path(dest: &Option<File>) -> &Path {
} }
} }
pub(crate) fn change_dir_and_return_parent(filename: &PathBuf) -> crate::Result<PathBuf> { pub(crate) fn change_dir_and_return_parent(filename: &Path) -> crate::Result<PathBuf> {
let previous_location = env::current_dir()?; let previous_location = env::current_dir()?;
let parent = if let Some(parent) = filename.parent() { let parent = if let Some(parent) = filename.parent() {
@ -73,7 +73,7 @@ pub(crate) fn change_dir_and_return_parent(filename: &PathBuf) -> crate::Result<
} }
pub fn permission_for_overwriting( pub fn permission_for_overwriting(
path: &PathBuf, path: &Path,
flags: Flags, flags: Flags,
confirm: &Confirmation, confirm: &Confirmation,
) -> crate::Result<bool> { ) -> crate::Result<bool> {
@ -83,6 +83,6 @@ pub fn permission_for_overwriting(
Flags::None => {} Flags::None => {}
} }
let file_path_str = &*path.as_path().to_string_lossy(); let file_path_str = path.to_string_lossy();
Ok(confirm.ask(Some(file_path_str))?) confirm.ask(Some(&file_path_str))
} }