pull/1082/head
Rafał Mikrut 8 months ago
parent cabcaaed26
commit 38c944e566

@ -33,8 +33,9 @@ fn main() {
setup_logger(true);
#[cfg(debug_assertions)]
println!("{command:?}");
if cfg!(debug_assertions) {
println!("{command:?}");
}
match command {
Commands::Duplicates(duplicates_args) => duplicates(duplicates_args),
@ -106,7 +107,9 @@ fn duplicates(duplicates: DuplicatesArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
if !cfg!(debug_assertions) {
df.print_results();
}
df.print_results();
df.get_text_messages().print_messages();
}
@ -143,8 +146,9 @@ fn empty_folders(empty_folders: EmptyFoldersArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
ef.print_results();
if !cfg!(debug_assertions) {
ef.print_results();
}
ef.get_text_messages().print_messages();
}
@ -192,8 +196,9 @@ fn biggest_files(biggest_files: BiggestFilesArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
bf.print_results();
if !cfg!(debug_assertions) {
bf.print_results();
}
bf.get_text_messages().print_messages();
}
@ -236,8 +241,9 @@ fn empty_files(empty_files: EmptyFilesArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
ef.print_results();
if !cfg!(debug_assertions) {
ef.print_results();
}
ef.get_text_messages().print_messages();
}
@ -278,8 +284,9 @@ fn temporary(temporary: TemporaryArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
tf.print_results();
if !cfg!(debug_assertions) {
tf.print_results();
}
tf.get_text_messages().print_messages();
}
@ -328,8 +335,9 @@ fn similar_images(similar_images: SimilarImagesArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
sf.print_results();
if !cfg!(debug_assertions) {
sf.print_results();
}
sf.get_text_messages().print_messages();
}
@ -376,8 +384,9 @@ fn same_music(same_music: SameMusicArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
mf.print_results();
if !cfg!(debug_assertions) {
mf.print_results();
}
mf.get_text_messages().print_messages();
}
@ -419,8 +428,9 @@ fn invalid_symlinks(invalid_symlinks: InvalidSymlinksArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
ifs.print_results();
if !cfg!(debug_assertions) {
ifs.print_results();
}
ifs.get_text_messages().print_messages();
}
@ -463,8 +473,9 @@ fn broken_files(broken_files: BrokenFilesArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
br.print_results();
if !cfg!(debug_assertions) {
br.print_results();
}
br.get_text_messages().print_messages();
}
@ -508,8 +519,9 @@ fn similar_videos(similar_videos: SimilarVideosArgs) {
}
}
#[cfg(not(debug_assertions))] // This will show too much probably unnecessary data to debug, comment line only if needed
vr.print_results();
if !cfg!(debug_assertions) {
vr.print_results();
}
vr.get_text_messages().print_messages();
}
@ -547,7 +559,8 @@ fn bad_extensions(bad_extensions: BadExtensionsArgs) {
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();
if !cfg!(debug_assertions) {
be.print_results();
}
be.get_text_messages().print_messages();
}

@ -222,12 +222,10 @@ impl BadExtensions {
.recursive_search(self.common_data.recursive_search)
.build()
.run();
debug!("check_files - collected files");
let res = match result {
match result {
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
if let Some(files_to_check) = grouped_file_entries.get(&()) {
self.files_to_check = files_to_check.clone();
}
self.files_to_check = grouped_file_entries.into_values().flatten().collect();
self.common_data.text_messages.warnings.extend(warnings);
true
@ -236,8 +234,7 @@ impl BadExtensions {
unreachable!()
}
DirTraversalResult::Stopped => false,
};
res
}
}
#[fun_time(message = "look_for_bad_extensions_files")]
@ -267,8 +264,7 @@ impl BadExtensions {
self.information.number_of_files_with_bad_extension = self.bad_extensions_files.len();
// Clean unused data
self.files_to_check = Default::default();
debug!("Found {} files with invalid extension.", self.information.number_of_files_with_bad_extension);
true
}
@ -407,11 +403,8 @@ impl Default for BadExtensions {
}
impl DebugPrint for BadExtensions {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");
@ -421,6 +414,7 @@ impl DebugPrint for BadExtensions {
}
impl SaveResults for BadExtensions {
#[fun_time(message = "save_results_to_file")]
fn save_results_to_file(&mut self, file_name: &str) -> bool {
let file_name: String = match file_name {
"" => "results.txt".to_string(),
@ -462,6 +456,7 @@ impl SaveResults for BadExtensions {
}
impl PrintResults for BadExtensions {
#[fun_time(message = "print_results")]
fn print_results(&self) {
println!("Found {} files with invalid extension.\n", self.information.number_of_files_with_bad_extension);
for file_entry in &self.bad_extensions_files {

@ -80,6 +80,7 @@ impl BigFile {
let (progress_thread_handle, progress_thread_run, atomic_counter, _check_was_stopped) =
prepare_thread_handler_common(progress_sender, 0, 0, 0, CheckingMethod::None, self.common_data.tool_type);
debug!("Starting to search for big files");
while !folders_to_check.is_empty() {
if stop_receiver.is_some() && stop_receiver.unwrap().try_recv().is_ok() {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
@ -133,6 +134,7 @@ impl BigFile {
}
}
}
debug!("Collected {} big files",);
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
@ -232,11 +234,8 @@ impl Default for BigFile {
}
impl DebugPrint for BigFile {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}

@ -452,11 +452,8 @@ impl Default for BrokenFiles {
}
impl DebugPrint for BrokenFiles {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");

@ -40,7 +40,7 @@ pub fn get_number_of_threads() -> usize {
fn filtering_messages(record: &Record) -> bool {
if let Some(module_path) = record.module_path() {
!["symphonia", "i18n_embed"].iter().any(|&x| module_path.contains(x))
module_path.starts_with("czkawka")
} else {
true
}
@ -225,16 +225,6 @@ pub fn create_crash_message(library_name: &str, file_path: &str, home_library_ur
}
impl Common {
#[allow(unused_variables)]
pub fn print_time(start_time: SystemTime, end_time: SystemTime, function_name: &str) {
#[cfg(debug_assertions)]
println!(
"Execution of function \"{}\" took {:?}",
function_name,
end_time.duration_since(start_time).expect("Time cannot go reverse.")
);
}
pub fn delete_multiple_entries(entries: &[String]) -> Vec<String> {
let mut path: &Path;
let mut warnings: Vec<String> = Vec::new();

@ -8,6 +8,7 @@ use std::time::UNIX_EPOCH;
use crossbeam_channel::Receiver;
use fun_time::fun_time;
use futures::channel::mpsc::UnboundedSender;
use log::debug;
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
@ -499,6 +500,12 @@ where
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
debug!(
"Collected {} files, {} folders",
grouped_file_entries.values().map(Vec::len).sum::<usize>(),
folder_entries.len()
);
match collect {
Collect::Files | Collect::InvalidSymlinks => DirTraversalResult::SuccessFiles {
grouped_file_entries,

@ -703,6 +703,7 @@ impl DuplicateFinder {
{
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.full_hashing_load_cache_at_start(pre_checked_map);
debug!("Starting full hashing of {} files", non_cached_files_to_check.values().map(Vec::len).sum::<usize>());
let mut full_hash_results: Vec<(u64, BTreeMap<String, Vec<FileEntry>>, Vec<String>)> = non_cached_files_to_check
.into_par_iter()
.map(|(size, vec_file_entry)| {
@ -729,6 +730,7 @@ impl DuplicateFinder {
})
.while_some()
.collect();
debug!("Finished full hashing");
self.full_hashing_save_cache_at_exit(records_already_cached, &mut full_hash_results, loaded_hash_map);
@ -951,12 +953,9 @@ impl Default for DuplicateFinder {
}
impl DebugPrint for DuplicateFinder {
#[allow(dead_code)]
#[allow(unreachable_code)]
/// Debugging printing - only available on debug build
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");

@ -115,11 +115,8 @@ impl Default for EmptyFiles {
}
impl DebugPrint for EmptyFiles {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");

@ -7,7 +7,6 @@ use std::path::PathBuf;
use crossbeam_channel::Receiver;
use fun_time::fun_time;
use futures::channel::mpsc::UnboundedSender;
use log::debug;
use crate::common_dir_traversal::{Collect, DirTraversalBuilder, DirTraversalResult, FolderEmptiness, FolderEntry, ProgressData, ToolType};
use crate::common_tool::{CommonData, CommonToolData};
@ -76,8 +75,8 @@ impl EmptyFolder {
self.information.number_of_empty_folders = self.empty_folder_list.len();
}
#[fun_time(message = "check_for_empty_folders")]
fn check_for_empty_folders(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
debug!("check_for_empty_folders - start");
let result = DirTraversalBuilder::new()
.root_dirs(self.common_data.directories.included_directories.clone())
.group_by(|_fe| ())
@ -89,15 +88,13 @@ impl EmptyFolder {
.max_stage(0)
.build()
.run();
debug!("check_for_empty_folders - collected folders to check");
let res = match result {
match result {
DirTraversalResult::SuccessFiles { .. } => {
unreachable!()
}
DirTraversalResult::SuccessFolders { folder_entries, warnings } => {
// We need to set empty folder list
#[allow(unused_mut)] // Used is later by Windows build
for (mut name, folder_entry) in folder_entries {
for (name, folder_entry) in folder_entries {
if folder_entry.is_empty != FolderEmptiness::No {
self.empty_folder_list.insert(name, folder_entry);
}
@ -108,11 +105,10 @@ impl EmptyFolder {
true
}
DirTraversalResult::Stopped => false,
};
debug!("check_for_empty_folders - end");
res
}
}
#[fun_time(message = "delete_empty_folders")]
fn delete_empty_folders(&mut self) {
// Folders may be deleted or require too big privileges
for name in self.empty_folder_list.keys() {
@ -135,11 +131,8 @@ impl Default for EmptyFolder {
}
impl DebugPrint for EmptyFolder {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
@ -151,6 +144,7 @@ impl DebugPrint for EmptyFolder {
}
impl SaveResults for EmptyFolder {
#[fun_time(message = "save_results_to_file")]
fn save_results_to_file(&mut self, file_name: &str) -> bool {
let file_name: String = match file_name {
"" => "results.txt".to_string(),

@ -98,11 +98,8 @@ impl Default for InvalidSymlinks {
}
impl DebugPrint for InvalidSymlinks {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");

@ -854,7 +854,6 @@ fn read_single_file_tag(path: &str, music_entry: &mut MusicEntry) -> bool {
genre = tag_value.to_string();
}
}
// println!("{:?}", tag.items());
}
if let Ok(old_length_number) = length.parse::<u32>() {
@ -864,7 +863,7 @@ fn read_single_file_tag(path: &str, music_entry: &mut MusicEntry) -> bool {
if minutes != 0 || seconds != 0 {
length = format!("{minutes}:{seconds:02}");
} else if old_length_number > 0 {
// That means, that audio have length smaller that second, but length is properly read
// That means, that audio have length smaller that second, but length was properly read
length = "0:01".to_string();
} else {
length = String::new();
@ -890,12 +889,9 @@ impl Default for SameMusic {
}
impl DebugPrint for SameMusic {
#[allow(dead_code)]
#[allow(unreachable_code)]
#[fun_time(message = "debug_print")]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("---------------DEBUG PRINT---------------");

@ -694,10 +694,8 @@ impl SimilarImages {
collected_similar_images.insert(hash, vec_file_entry);
}
}
} else {
if !self.compare_hashes_with_non_zero_tolerance(&all_hashed_images, &mut collected_similar_images, progress_sender, stop_receiver, tolerance) {
return false;
}
} else if !self.compare_hashes_with_non_zero_tolerance(&all_hashed_images, &mut collected_similar_images, progress_sender, stop_receiver, tolerance) {
return false;
}
self.verify_duplicated_items(&collected_similar_images);
@ -768,13 +766,12 @@ impl SimilarImages {
}
}
#[allow(dead_code)]
#[allow(unreachable_code)]
#[allow(unused_variables)]
// TODO this probably not works good when reference folders are used
pub fn verify_duplicated_items(&self, collected_similar_images: &HashMap<ImHash, Vec<FileEntry>>) {
#[cfg(not(debug_assertions))]
return;
if !cfg!(debug_assertions) {
return;
}
// Validating if group contains duplicated results
let mut result_hashset: HashSet<String> = Default::default();
let mut found = false;
@ -815,11 +812,8 @@ impl Default for SimilarImages {
}
impl DebugPrint for SimilarImages {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
@ -1030,8 +1024,9 @@ fn debug_check_for_duplicated_things(
all_hashed_images: &HashMap<ImHash, Vec<FileEntry>>,
numm: &str,
) {
#[cfg(not(debug_assertions))]
return;
if !cfg!(debug_assertions) {
return;
}
if use_reference_folders {
return;

@ -410,12 +410,9 @@ impl Default for SimilarVideos {
}
impl DebugPrint for SimilarVideos {
#[allow(dead_code)]
#[allow(unreachable_code)]
#[fun_time(message = "debug_print")]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}

@ -252,11 +252,8 @@ impl Default for Temporary {
}
impl DebugPrint for Temporary {
#[allow(dead_code)]
#[allow(unreachable_code)]
fn debug_print(&self) {
#[cfg(not(debug_assertions))]
{
if !cfg!(debug_assertions) {
return;
}
println!("### Information's");

@ -4,11 +4,11 @@ use std::sync::Arc;
use std::thread;
use crossbeam_channel::Receiver;
use fun_time::fun_time;
use futures::channel::mpsc::UnboundedSender;
use glib::Sender;
use gtk4::prelude::*;
use gtk4::Grid;
use log::debug;
use czkawka_core::bad_extensions::BadExtensions;
use czkawka_core::big_file::BigFile;
@ -794,9 +794,8 @@ fn bad_extensions_search(
});
}
#[fun_time(message = "clean_tree_view")]
fn clean_tree_view(tree_view: &gtk4::TreeView) {
debug!("Start clean tree view");
let list_store = get_list_store(tree_view);
list_store.clear();
debug!("Cleared tree view");
}

@ -14,8 +14,8 @@ pub fn opening_enter_function_ported_upper_directories(
_modifier_type: ModifierType,
) -> glib::Propagation {
let tree_view = event_controller.widget().downcast::<gtk4::TreeView>().unwrap();
#[cfg(debug_assertions)]
{
if cfg!(debug_assertions) {
println!("key_code {key_code}");
}
@ -70,8 +70,7 @@ pub fn opening_double_click_function_directories(gesture_click: &GestureClick, n
pub fn opening_enter_function_ported(event_controller: &gtk4::EventControllerKey, _key: Key, key_code: u32, _modifier_type: ModifierType) -> glib::Propagation {
let tree_view = event_controller.widget().downcast::<gtk4::TreeView>().unwrap();
#[cfg(debug_assertions)]
{
if cfg!(debug_assertions) {
println!("key_code {key_code}");
}

Loading…
Cancel
Save