Allow to find the smallest files from CLo
This commit is contained in:
parent
c8f9caedfd
commit
9a1e49f424
|
@ -62,7 +62,7 @@ pub enum Commands {
|
|||
#[clap(flatten)]
|
||||
exclude_other_filesystems: ExcludeOtherFilesystems,
|
||||
},
|
||||
#[clap(name = "big", about = "Finds big files", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka big -d /home/rafal/ /home/piszczal -e /home/rafal/Roman -n 25 -x VIDEO -f results.txt")]
|
||||
#[clap(name = "big", about = "Finds big files", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka big -d /home/rafal/ /home/piszczal -e /home/rafal/Roman -n 25 -J -x VIDEO -f results.txt")]
|
||||
BiggestFiles {
|
||||
#[clap(flatten)]
|
||||
directories: Directories,
|
||||
|
@ -80,6 +80,8 @@ pub enum Commands {
|
|||
file_to_save: FileToSave,
|
||||
#[clap(flatten)]
|
||||
not_recursive: NotRecursive,
|
||||
#[clap(short = 'J', long, help = "Finds the smallest files instead the biggest")]
|
||||
smallest_mode: bool,
|
||||
#[cfg(target_family = "unix")]
|
||||
#[clap(flatten)]
|
||||
exclude_other_filesystems: ExcludeOtherFilesystems,
|
||||
|
|
|
@ -5,20 +5,21 @@ use std::process;
|
|||
use clap::Parser;
|
||||
|
||||
use commands::Commands;
|
||||
use czkawka_core::big_file::SearchMode;
|
||||
#[allow(unused_imports)] // It is used in release for print_results().
|
||||
use czkawka_core::common_traits::*;
|
||||
use czkawka_core::similar_images::test_image_conversion_speed;
|
||||
use czkawka_core::{
|
||||
bad_extensions::{self, BadExtensions},
|
||||
bad_extensions::BadExtensions,
|
||||
big_file::{self, BigFile},
|
||||
broken_files::{self, BrokenFiles},
|
||||
duplicate::{self, DuplicateFinder},
|
||||
duplicate::DuplicateFinder,
|
||||
empty_files::{self, EmptyFiles},
|
||||
empty_folder::{self, EmptyFolder},
|
||||
empty_folder::EmptyFolder,
|
||||
invalid_symlinks::{self, InvalidSymlinks},
|
||||
same_music::{self, SameMusic},
|
||||
similar_images::{self, return_similarity_from_similarity_preset, SimilarImages},
|
||||
similar_videos::{self, SimilarVideos},
|
||||
same_music::SameMusic,
|
||||
similar_images::{return_similarity_from_similarity_preset, SimilarImages},
|
||||
similar_videos::SimilarVideos,
|
||||
temporary::{self, Temporary},
|
||||
};
|
||||
|
||||
|
@ -125,6 +126,7 @@ fn main() {
|
|||
#[cfg(target_family = "unix")]
|
||||
exclude_other_filesystems,
|
||||
delete_files,
|
||||
smallest_mode,
|
||||
} => {
|
||||
let mut bf = BigFile::new();
|
||||
|
||||
|
@ -139,6 +141,9 @@ fn main() {
|
|||
if delete_files {
|
||||
bf.set_delete_method(big_file::DeleteMethod::Delete);
|
||||
}
|
||||
if smallest_mode {
|
||||
bf.set_search_mode(SearchMode::SmallestFiles);
|
||||
}
|
||||
|
||||
bf.find_big_files(None, None);
|
||||
|
||||
|
@ -454,6 +459,8 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
be.find_bad_extensions_files(None, None);
|
||||
|
||||
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
|
||||
be.print_results();
|
||||
be.get_text_messages().print_messages();
|
||||
|
|
|
@ -469,7 +469,7 @@ impl BadExtensions {
|
|||
|
||||
self.information.number_of_files_with_bad_extension = self.bad_extensions_files.len();
|
||||
|
||||
Common::print_time(system_time, SystemTime::now(), "sort_images - reading data from files in parallel".to_string());
|
||||
Common::print_time(system_time, SystemTime::now(), "bad extension finding".to_string());
|
||||
|
||||
// Clean unused data
|
||||
self.files_to_check = Default::default();
|
||||
|
@ -539,7 +539,7 @@ impl SaveResults for BadExtensions {
|
|||
if !self.bad_extensions_files.is_empty() {
|
||||
writeln!(writer, "Found {} files with invalid extension.", self.information.number_of_files_with_bad_extension).unwrap();
|
||||
for file_entry in self.bad_extensions_files.iter() {
|
||||
writeln!(writer, "{}", file_entry.path.display()).unwrap();
|
||||
writeln!(writer, "{} ----- {}", file_entry.path.display(), file_entry.proper_extensions).unwrap();
|
||||
}
|
||||
} else {
|
||||
write!(writer, "Not found any files with invalid extension.").unwrap();
|
||||
|
@ -556,7 +556,7 @@ impl PrintResults for BadExtensions {
|
|||
let start_time: SystemTime = SystemTime::now();
|
||||
println!("Found {} files with invalid extension.\n", self.information.number_of_files_with_bad_extension);
|
||||
for file_entry in self.bad_extensions_files.iter() {
|
||||
println!("{}", file_entry.path.display());
|
||||
println!("{} ----- {}", file_entry.path.display(), file_entry.proper_extensions);
|
||||
}
|
||||
|
||||
Common::print_time(start_time, SystemTime::now(), "print_entries".to_string());
|
||||
|
|
|
@ -464,9 +464,12 @@ impl SaveResults for BigFile {
|
|||
}
|
||||
|
||||
if self.information.number_of_real_files != 0 {
|
||||
write!(writer, "{} the biggest files.\n\n", self.information.number_of_real_files).unwrap();
|
||||
|
||||
for (size, file_entry) in self.big_files.iter().rev() {
|
||||
if self.search_mode == SearchMode::BiggestFiles {
|
||||
write!(writer, "{} the biggest files.\n\n", self.information.number_of_real_files).unwrap();
|
||||
} else {
|
||||
write!(writer, "{} the smallest files.\n\n", self.information.number_of_real_files).unwrap();
|
||||
}
|
||||
for (size, file_entry) in self.big_files.iter() {
|
||||
writeln!(writer, "{} ({}) - {}", size.file_size(options::BINARY).unwrap(), size, file_entry.path.display()).unwrap();
|
||||
}
|
||||
} else {
|
||||
|
@ -480,9 +483,13 @@ impl SaveResults for BigFile {
|
|||
impl PrintResults for BigFile {
|
||||
fn print_results(&self) {
|
||||
let start_time: SystemTime = SystemTime::now();
|
||||
for (size, file_entry) in self.big_files.iter().rev() {
|
||||
// TODO Align all to same width
|
||||
println!("{} ({} bytes) - {}", size.file_size(options::BINARY).unwrap(), size, file_entry.path.display());
|
||||
if self.search_mode == SearchMode::BiggestFiles {
|
||||
println!("{} the biggest files.\n\n", self.information.number_of_real_files);
|
||||
} else {
|
||||
println!("{} the smallest files.\n\n", self.information.number_of_real_files);
|
||||
}
|
||||
for (size, file_entry) in self.big_files.iter() {
|
||||
println!("{} ({}) - {}", size.file_size(options::BINARY).unwrap(), size, file_entry.path.display());
|
||||
}
|
||||
Common::print_time(start_time, SystemTime::now(), "print_entries".to_string());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue