letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
@ -101,6 +110,9 @@ impl BigFile {
letmutcurrent_folder: String;
letmutcurrent_folder: String;
letmutnext_folder: String;
letmutnext_folder: String;
while!folders_to_check.is_empty(){
while!folders_to_check.is_empty(){
ifrx.is_some()&&rx.unwrap().try_recv().is_ok(){
returnfalse;
}
current_folder=folders_to_check.pop().unwrap();
current_folder=folders_to_check.pop().unwrap();
letread_dir=matchfs::read_dir(¤t_folder){
letread_dir=matchfs::read_dir(¤t_folder){
@ -127,10 +139,6 @@ impl BigFile {
};
};
ifmetadata.is_dir(){
ifmetadata.is_dir(){
self.information.number_of_checked_folders+=1;
self.information.number_of_checked_folders+=1;
// if entry_data.file_name().into_string().is_err() { // Probably this can be removed, if crash still will be happens, then uncomment this line
// self.text_messages.warnings.push("Cannot read folder name in dir ".to_string() + current_folder.as_str());
// TODO maybe add multithreading checking for file hash
// TODO maybe add multithreading checking for file hash
letstart_time: SystemTime=SystemTime::now();
letstart_time: SystemTime=SystemTime::now();
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
@ -176,6 +189,9 @@ impl DuplicateFinder {
letmutcurrent_folder: String;
letmutcurrent_folder: String;
letmutnext_folder: String;
letmutnext_folder: String;
while!folders_to_check.is_empty(){
while!folders_to_check.is_empty(){
ifrx.is_some()&&rx.unwrap().try_recv().is_ok(){
returnfalse;
}
current_folder=folders_to_check.pop().unwrap();
current_folder=folders_to_check.pop().unwrap();
// Read current dir, if permission are denied just go to next
// Read current dir, if permission are denied just go to next
@ -205,10 +221,6 @@ impl DuplicateFinder {
};
};
ifmetadata.is_dir(){
ifmetadata.is_dir(){
self.information.number_of_checked_folders+=1;
self.information.number_of_checked_folders+=1;
// if entry_data.file_name().into_string().is_err() { // Probably this can be removed, if crash still will be happens, then uncomment this line
// self.text_messages.warnings.push("Cannot read folder name in dir ".to_string() + current_folder.as_str());
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
@ -122,6 +132,9 @@ impl EmptyFiles {
letmutcurrent_folder: String;
letmutcurrent_folder: String;
letmutnext_folder: String;
letmutnext_folder: String;
while!folders_to_check.is_empty(){
while!folders_to_check.is_empty(){
ifrx.is_some()&&rx.unwrap().try_recv().is_ok(){
returnfalse;
}
current_folder=folders_to_check.pop().unwrap();
current_folder=folders_to_check.pop().unwrap();
// Read current dir, if permission are denied just go to next
// Read current dir, if permission are denied just go to next
@ -151,10 +164,6 @@ impl EmptyFiles {
};
};
ifmetadata.is_dir(){
ifmetadata.is_dir(){
self.information.number_of_checked_folders+=1;
self.information.number_of_checked_folders+=1;
// if entry_data.file_name().into_string().is_err() { // Probably this can be removed, if crash still will be happens, then uncomment this line
// self.text_messages.warnings.push("Cannot read folder name in dir ".to_string() + current_folder.as_str());
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
// Checked folder may be deleted or we may not have permissions to open it so we assume that this folder is not be empty
// Checked folder may be deleted or we may not have permissions to open it so we assume that this folder is not be empty
@ -214,26 +211,15 @@ impl EmptyFolder {
}
}
}
}
// Now we check if checked folders are really empty, and if are, then
ifinitial_checking{
// We need to set empty folder list
// We need to set empty folder list
for(name,folder_entry)infolders_checked{
for(name,folder_entry)infolders_checked{
iffolder_entry.is_empty!=FolderEmptiness::No{
iffolder_entry.is_empty!=FolderEmptiness::No{
self.empty_folder_list.insert(name,folder_entry);
self.empty_folder_list.insert(name,folder_entry);
}
}
}
}
}else{
// We need to check if parent of folder isn't also empty, because we want to delete only parent with two empty folders except this folders and at the end parent folder
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
@ -114,6 +123,9 @@ impl Temporary {
letmutcurrent_folder: String;
letmutcurrent_folder: String;
letmutnext_folder: String;
letmutnext_folder: String;
while!folders_to_check.is_empty(){
while!folders_to_check.is_empty(){
ifrx.is_some()&&rx.unwrap().try_recv().is_ok(){
returnfalse;
}
current_folder=folders_to_check.pop().unwrap();
current_folder=folders_to_check.pop().unwrap();
// Read current dir, if permission are denied just go to next
// Read current dir, if permission are denied just go to next
@ -143,10 +155,6 @@ impl Temporary {
};
};
ifmetadata.is_dir(){
ifmetadata.is_dir(){
self.information.number_of_checked_folders+=1;
self.information.number_of_checked_folders+=1;
// if entry_data.file_name().into_string().is_err() { // Probably this can be removed, if crash still will be happens, then uncomment this line
// self.text_messages.warnings.push("Cannot read folder name in dir ".to_string() + current_folder.as_str());