mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
fix: apply clippy lints
This commit is contained in:
parent
5d27a0cd0b
commit
5dc8d3efed
@ -61,7 +61,7 @@ where
|
||||
_is_file @ false => {
|
||||
if let Some(path) = file_path.parent() {
|
||||
if !path.exists() {
|
||||
fs::create_dir_all(&path)?;
|
||||
fs::create_dir_all(path)?;
|
||||
}
|
||||
}
|
||||
let file_path = strip_cur_dir(file_path.as_path());
|
||||
@ -69,7 +69,7 @@ where
|
||||
// same reason is in _is_dir: long, often not needed text
|
||||
info!(@display_handle, inaccessible, "{:?} extracted. ({})", file_path.display(), Bytes::new(file.size()));
|
||||
|
||||
let mut output_file = fs::File::create(&file_path)?;
|
||||
let mut output_file = fs::File::create(file_path)?;
|
||||
io::copy(&mut file, &mut output_file)?;
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -34,7 +34,7 @@ pub fn decompress_file(
|
||||
) -> crate::Result<()> {
|
||||
assert!(output_dir.exists());
|
||||
let total_input_size = input_file_path.metadata().expect("file exists").len();
|
||||
let reader = fs::File::open(&input_file_path)?;
|
||||
let reader = fs::File::open(input_file_path)?;
|
||||
|
||||
// Zip archives are special, because they require io::Seek, so it requires it's logic separated
|
||||
// from decoder chaining.
|
||||
@ -204,10 +204,10 @@ fn smart_unpack(
|
||||
.unwrap_or(&mut io::stdout()),
|
||||
)?;
|
||||
|
||||
let root_contains_only_one_element = fs::read_dir(&temp_dir_path)?.count() == 1;
|
||||
let root_contains_only_one_element = fs::read_dir(temp_dir_path)?.count() == 1;
|
||||
if root_contains_only_one_element {
|
||||
// Only one file in the root directory, so we can just move it to the output directory
|
||||
let file = fs::read_dir(&temp_dir_path)?.next().expect("item exists")?;
|
||||
let file = fs::read_dir(temp_dir_path)?.next().expect("item exists")?;
|
||||
let file_path = file.path();
|
||||
let file_name = file_path
|
||||
.file_name()
|
||||
@ -231,7 +231,7 @@ fn smart_unpack(
|
||||
if !utils::clear_path(output_file_path, question_policy)? {
|
||||
return Ok(ControlFlow::Break(()));
|
||||
}
|
||||
fs::rename(&temp_dir_path, &output_file_path)?;
|
||||
fs::rename(temp_dir_path, output_file_path)?;
|
||||
info!(
|
||||
accessible,
|
||||
"Successfully moved {} to {}.",
|
||||
|
@ -21,7 +21,7 @@ pub fn list_archive_contents(
|
||||
list_options: ListOptions,
|
||||
question_policy: QuestionPolicy,
|
||||
) -> crate::Result<()> {
|
||||
let reader = fs::File::open(&archive_path)?;
|
||||
let reader = fs::File::open(archive_path)?;
|
||||
|
||||
// Zip archives are special, because they require io::Seek, so it requires it's logic separated
|
||||
// from decoder chaining.
|
||||
|
@ -94,7 +94,7 @@ pub fn try_infer_extension(path: &Path) -> Option<Extension> {
|
||||
let mut buf = [0; 270];
|
||||
|
||||
// Error cause will be ignored, so use std::fs instead of fs_err
|
||||
let result = std::fs::File::open(&path).map(|mut file| file.read(&mut buf));
|
||||
let result = std::fs::File::open(path).map(|mut file| file.read(&mut buf));
|
||||
|
||||
// In case of file open or read failure, could not infer a extension
|
||||
if result.is_err() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user