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

View File

@ -11,7 +11,7 @@ use super::decompressor::{DecompressionResult, Decompressor};
use crate::{cli::Flags, dialogs::Confirmation, file::File, utils};
#[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;
if let Some(mode) = file.unix_mode() {
@ -52,11 +52,11 @@ impl ZipDecompressor {
};
let file_path = into.join(file_path);
if file_path.exists() {
if !utils::permission_for_overwriting(&file_path, flags, &confirm)? {
// The user does not want to overwrite the file
continue;
}
if file_path.exists()
&& !utils::permission_for_overwriting(&file_path, flags, &confirm)?
{
// The user does not want to overwrite the file
continue;
}
Self::check_for_comments(&file);

View File

@ -162,11 +162,11 @@ impl Evaluator {
// TODO: use -y and -n here
let output_path = output.path.clone();
if output_path.exists() {
if !utils::permission_for_overwriting(&output_path, flags, &confirm)? {
// The user does not want to overwrite the file
return Ok(());
}
if output_path.exists()
&& !utils::permission_for_overwriting(&output_path, flags, &confirm)?
{
// The user does not want to overwrite the file
return Ok(());
}
let bytes = match 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 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(
path: &PathBuf,
path: &Path,
flags: Flags,
confirm: &Confirmation,
) -> crate::Result<bool> {
@ -83,6 +83,6 @@ pub fn permission_for_overwriting(
Flags::None => {}
}
let file_path_str = &*path.as_path().to_string_lossy();
Ok(confirm.ask(Some(file_path_str))?)
let file_path_str = path.to_string_lossy();
confirm.ask(Some(&file_path_str))
}