Remove ugly time checking
This commit is contained in:
parent
5d4871c83d
commit
e60b409505
|
@ -6,14 +6,14 @@ use std::mem;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
use mime_guess::get_mime_extensions;
|
use mime_guess::get_mime_extensions;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::common::{prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, Common};
|
use crate::common::{prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads};
|
||||||
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -298,16 +298,12 @@ impl BadExtensions {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
if let Some(files_to_check) = grouped_file_entries.get(&()) {
|
if let Some(files_to_check) = grouped_file_entries.get(&()) {
|
||||||
self.files_to_check = files_to_check.clone();
|
self.files_to_check = files_to_check.clone();
|
||||||
}
|
}
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -318,8 +314,6 @@ impl BadExtensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn look_for_bad_extensions_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn look_for_bad_extensions_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let system_time = SystemTime::now();
|
|
||||||
|
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
|
|
||||||
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
||||||
|
@ -357,8 +351,6 @@ impl BadExtensions {
|
||||||
|
|
||||||
self.information.number_of_files_with_bad_extension = self.bad_extensions_files.len();
|
self.information.number_of_files_with_bad_extension = self.bad_extensions_files.len();
|
||||||
|
|
||||||
Common::print_time(system_time, SystemTime::now(), "bad extension finding");
|
|
||||||
|
|
||||||
// Clean unused data
|
// Clean unused data
|
||||||
self.files_to_check = Default::default();
|
self.files_to_check = Default::default();
|
||||||
|
|
||||||
|
@ -525,7 +517,6 @@ impl DebugPrint for BadExtensions {
|
||||||
|
|
||||||
impl SaveResults for BadExtensions {
|
impl SaveResults for BadExtensions {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -557,7 +548,7 @@ impl SaveResults for BadExtensions {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any files with invalid extension.").unwrap();
|
write!(writer, "Not found any files with invalid extension.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,12 +557,9 @@ impl PrintResults for BadExtensions {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} files with invalid extension.\n", self.information.number_of_files_with_bad_extension);
|
println!("Found {} files with invalid extension.\n", self.information.number_of_files_with_bad_extension);
|
||||||
for file_entry in &self.bad_extensions_files {
|
for file_entry in &self.bad_extensions_files {
|
||||||
println!("{} ----- {}", file_entry.path.display(), file_entry.proper_extensions);
|
println!("{} ----- {}", file_entry.path.display(), file_entry.proper_extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
|
@ -14,7 +14,7 @@ use humansize::format_size;
|
||||||
use humansize::BINARY;
|
use humansize::BINARY;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::common::Common;
|
|
||||||
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, split_path};
|
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, split_path};
|
||||||
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
|
@ -142,7 +142,6 @@ impl BigFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn look_for_big_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn look_for_big_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
let mut old_map: BTreeMap<u64, Vec<FileEntry>> = Default::default();
|
let mut old_map: BTreeMap<u64, Vec<FileEntry>> = Default::default();
|
||||||
|
|
||||||
|
@ -213,7 +212,6 @@ impl BigFile {
|
||||||
|
|
||||||
self.extract_n_biggest_files(old_map);
|
self.extract_n_biggest_files(old_map);
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "look_for_big_files");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,8 +306,6 @@ impl BigFile {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
match self.delete_method {
|
match self.delete_method {
|
||||||
DeleteMethod::Delete => {
|
DeleteMethod::Delete => {
|
||||||
for (_, file_entry) in &self.big_files {
|
for (_, file_entry) in &self.big_files {
|
||||||
|
@ -322,8 +318,6 @@ impl BigFile {
|
||||||
//Just do nothing
|
//Just do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +359,6 @@ impl DebugPrint for BigFile {
|
||||||
impl SaveResults for BigFile {
|
impl SaveResults for BigFile {
|
||||||
/// Saving results to provided file
|
/// Saving results to provided file
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -401,14 +394,13 @@ impl SaveResults for BigFile {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any files.").unwrap();
|
write!(writer, "Not found any files.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrintResults for BigFile {
|
impl PrintResults for BigFile {
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
if self.search_mode == SearchMode::BiggestFiles {
|
if self.search_mode == SearchMode::BiggestFiles {
|
||||||
println!("{} the biggest files.\n\n", self.information.number_of_real_files);
|
println!("{} the biggest files.\n\n", self.information.number_of_real_files);
|
||||||
} else {
|
} else {
|
||||||
|
@ -417,6 +409,5 @@ impl PrintResults for BigFile {
|
||||||
for (size, file_entry) in &self.big_files {
|
for (size, file_entry) in &self.big_files {
|
||||||
println!("{} ({}) - {}", format_size(*size, BINARY), size, file_entry.path.display());
|
println!("{} ({}) - {}", format_size(*size, BINARY), size, file_entry.path.display());
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::io::{BufReader, BufWriter};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
use std::{fs, mem, panic};
|
use std::{fs, mem, panic};
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
|
@ -18,7 +18,7 @@ use rayon::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
check_folder_children, create_crash_message, open_cache_folder, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, Common, PDF_FILES_EXTENSIONS,
|
check_folder_children, create_crash_message, open_cache_folder, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, PDF_FILES_EXTENSIONS,
|
||||||
};
|
};
|
||||||
use crate::common::{AUDIO_FILES_EXTENSIONS, IMAGE_RS_BROKEN_FILES_EXTENSIONS, ZIP_FILES_EXTENSIONS};
|
use crate::common::{AUDIO_FILES_EXTENSIONS, IMAGE_RS_BROKEN_FILES_EXTENSIONS, ZIP_FILES_EXTENSIONS};
|
||||||
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
||||||
|
@ -193,7 +193,6 @@ impl BrokenFiles {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn check_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
|
|
||||||
// Add root folders for finding
|
// Add root folders for finding
|
||||||
|
@ -263,7 +262,6 @@ impl BrokenFiles {
|
||||||
|
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn get_file_entry(
|
fn get_file_entry(
|
||||||
|
@ -405,8 +403,6 @@ impl BrokenFiles {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn look_for_broken_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn look_for_broken_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let system_time = SystemTime::now();
|
|
||||||
|
|
||||||
let loaded_hash_map;
|
let loaded_hash_map;
|
||||||
|
|
||||||
let mut records_already_cached: BTreeMap<String, FileEntry> = Default::default();
|
let mut records_already_cached: BTreeMap<String, FileEntry> = Default::default();
|
||||||
|
@ -479,9 +475,7 @@ impl BrokenFiles {
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
// Just connect loaded results with already calculated
|
// Just connect loaded results with already calculated
|
||||||
for (_name, file_entry) in records_already_cached {
|
vec_file_entry.extend(records_already_cached.into_values());
|
||||||
vec_file_entry.push(file_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.use_cache {
|
if self.use_cache {
|
||||||
// Must save all results to file, old loaded from file with all currently counted results
|
// Must save all results to file, old loaded from file with all currently counted results
|
||||||
|
@ -503,8 +497,6 @@ impl BrokenFiles {
|
||||||
|
|
||||||
self.information.number_of_broken_files = self.broken_files.len();
|
self.information.number_of_broken_files = self.broken_files.len();
|
||||||
|
|
||||||
Common::print_time(system_time, SystemTime::now(), "sort_images - reading data from files in parallel");
|
|
||||||
|
|
||||||
// Clean unused data
|
// Clean unused data
|
||||||
self.files_to_check = Default::default();
|
self.files_to_check = Default::default();
|
||||||
|
|
||||||
|
@ -513,8 +505,6 @@ impl BrokenFiles {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
match self.delete_method {
|
match self.delete_method {
|
||||||
DeleteMethod::Delete => {
|
DeleteMethod::Delete => {
|
||||||
for file_entry in &self.broken_files {
|
for file_entry in &self.broken_files {
|
||||||
|
@ -527,8 +517,6 @@ impl BrokenFiles {
|
||||||
//Just do nothing
|
//Just do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +557,6 @@ impl DebugPrint for BrokenFiles {
|
||||||
|
|
||||||
impl SaveResults for BrokenFiles {
|
impl SaveResults for BrokenFiles {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -601,7 +588,7 @@ impl SaveResults for BrokenFiles {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any broken files.").unwrap();
|
write!(writer, "Not found any broken files.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,13 +597,10 @@ impl PrintResults for BrokenFiles {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} broken files.\n", self.information.number_of_broken_files);
|
println!("Found {} broken files.\n", self.information.number_of_broken_files);
|
||||||
for file_entry in &self.broken_files {
|
for file_entry in &self.broken_files {
|
||||||
println!("{} - {}", file_entry.path.display(), file_entry.error_string);
|
println!("{} - {}", file_entry.path.display(), file_entry.error_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::fs::{DirEntry, Metadata, ReadDir};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{UNIX_EPOCH};
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
|
@ -280,12 +280,10 @@ impl<'a, 'b, F> DirTraversalBuilder<'a, 'b, F> {
|
||||||
|
|
||||||
pub enum DirTraversalResult<T: Ord + PartialOrd> {
|
pub enum DirTraversalResult<T: Ord + PartialOrd> {
|
||||||
SuccessFiles {
|
SuccessFiles {
|
||||||
start_time: SystemTime,
|
|
||||||
warnings: Vec<String>,
|
warnings: Vec<String>,
|
||||||
grouped_file_entries: BTreeMap<T, Vec<FileEntry>>,
|
grouped_file_entries: BTreeMap<T, Vec<FileEntry>>,
|
||||||
},
|
},
|
||||||
SuccessFolders {
|
SuccessFolders {
|
||||||
start_time: SystemTime,
|
|
||||||
warnings: Vec<String>,
|
warnings: Vec<String>,
|
||||||
folder_entries: BTreeMap<PathBuf, FolderEntry>, // Path, FolderEntry
|
folder_entries: BTreeMap<PathBuf, FolderEntry>, // Path, FolderEntry
|
||||||
},
|
},
|
||||||
|
@ -314,7 +312,6 @@ where
|
||||||
let mut all_warnings = vec![];
|
let mut all_warnings = vec![];
|
||||||
let mut grouped_file_entries: BTreeMap<T, Vec<FileEntry>> = BTreeMap::new();
|
let mut grouped_file_entries: BTreeMap<T, Vec<FileEntry>> = BTreeMap::new();
|
||||||
let mut folder_entries: BTreeMap<PathBuf, FolderEntry> = BTreeMap::new();
|
let mut folder_entries: BTreeMap<PathBuf, FolderEntry> = BTreeMap::new();
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
// Add root folders into result (only for empty folder collection)
|
// Add root folders into result (only for empty folder collection)
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
|
@ -468,12 +465,10 @@ where
|
||||||
|
|
||||||
match collect {
|
match collect {
|
||||||
Collect::Files | Collect::InvalidSymlinks => DirTraversalResult::SuccessFiles {
|
Collect::Files | Collect::InvalidSymlinks => DirTraversalResult::SuccessFiles {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
grouped_file_entries,
|
||||||
warnings: all_warnings,
|
warnings: all_warnings,
|
||||||
},
|
},
|
||||||
Collect::EmptyFolders => DirTraversalResult::SuccessFolders {
|
Collect::EmptyFolders => DirTraversalResult::SuccessFolders {
|
||||||
start_time,
|
|
||||||
folder_entries,
|
folder_entries,
|
||||||
warnings: all_warnings,
|
warnings: all_warnings,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::SystemTime;
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use std::{fs, os::unix::fs::MetadataExt};
|
use std::{fs, os::unix::fs::MetadataExt};
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ impl Directories {
|
||||||
|
|
||||||
/// Setting included directories, at least one must be provided or scan won't start
|
/// Setting included directories, at least one must be provided or scan won't start
|
||||||
pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>, text_messages: &mut Messages) -> bool {
|
pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>, text_messages: &mut Messages) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
if included_directory.is_empty() {
|
if included_directory.is_empty() {
|
||||||
text_messages.errors.push(flc!("core_missing_no_chosen_included_directory"));
|
text_messages.errors.push(flc!("core_missing_no_chosen_included_directory"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -90,13 +88,11 @@ impl Directories {
|
||||||
|
|
||||||
self.included_directories = checked_directories;
|
self.included_directories = checked_directories;
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "set_included_directory");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setting absolute path to exclude from search
|
/// Setting absolute path to exclude from search
|
||||||
pub fn set_excluded_directory(&mut self, excluded_directory: Vec<PathBuf>, text_messages: &mut Messages) {
|
pub fn set_excluded_directory(&mut self, excluded_directory: Vec<PathBuf>, text_messages: &mut Messages) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
if excluded_directory.is_empty() {
|
if excluded_directory.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -148,8 +144,6 @@ impl Directories {
|
||||||
checked_directories.push(directory);
|
checked_directories.push(directory);
|
||||||
}
|
}
|
||||||
self.excluded_directories = checked_directories;
|
self.excluded_directories = checked_directories;
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "set_excluded_directory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
|
@ -159,8 +153,6 @@ impl Directories {
|
||||||
|
|
||||||
/// Remove unused entries when included or excluded overlaps with each other or are duplicated etc.
|
/// Remove unused entries when included or excluded overlaps with each other or are duplicated etc.
|
||||||
pub fn optimize_directories(&mut self, recursive_search: bool, text_messages: &mut Messages) -> bool {
|
pub fn optimize_directories(&mut self, recursive_search: bool, text_messages: &mut Messages) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
let mut optimized_included: Vec<PathBuf> = Vec::new();
|
let mut optimized_included: Vec<PathBuf> = Vec::new();
|
||||||
let mut optimized_excluded: Vec<PathBuf> = Vec::new();
|
let mut optimized_excluded: Vec<PathBuf> = Vec::new();
|
||||||
|
|
||||||
|
@ -295,7 +287,6 @@ impl Directories {
|
||||||
// Not needed, but better is to have sorted everything
|
// Not needed, but better is to have sorted everything
|
||||||
self.excluded_directories.sort_unstable();
|
self.excluded_directories.sort_unstable();
|
||||||
self.included_directories.sort_unstable();
|
self.included_directories.sort_unstable();
|
||||||
Common::print_time(start_time, SystemTime::now(), "optimize_directories");
|
|
||||||
|
|
||||||
// Get device IDs for included directories
|
// Get device IDs for included directories
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crate::common::Common;
|
|
||||||
|
|
||||||
use crate::common_messages::Messages;
|
use crate::common_messages::Messages;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
|
@ -16,7 +16,6 @@ impl Extensions {
|
||||||
/// List of allowed extensions, only files with this extensions will be checking if are duplicates
|
/// List of allowed extensions, only files with this extensions will be checking if are duplicates
|
||||||
/// After, extensions cannot contains any dot, commas etc.
|
/// After, extensions cannot contains any dot, commas etc.
|
||||||
pub fn set_allowed_extensions(&mut self, mut allowed_extensions: String, text_messages: &mut Messages) {
|
pub fn set_allowed_extensions(&mut self, mut allowed_extensions: String, text_messages: &mut Messages) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
if allowed_extensions.trim().is_empty() {
|
if allowed_extensions.trim().is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +56,6 @@ impl Extensions {
|
||||||
.messages
|
.messages
|
||||||
.push("No valid extensions were provided, so allowing all extensions by default.".to_string());
|
.push("No valid extensions were provided, so allowing all extensions by default.".to_string());
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "set_allowed_extensions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crate::common::Common;
|
use crate::common::Common;
|
||||||
use crate::common_messages::Messages;
|
use crate::common_messages::Messages;
|
||||||
|
@ -17,8 +17,6 @@ impl ExcludedItems {
|
||||||
/// Setting excluded items which needs to contains * wildcard
|
/// Setting excluded items which needs to contains * wildcard
|
||||||
/// Are a lot of slower than absolute path, so it should be used to heavy
|
/// Are a lot of slower than absolute path, so it should be used to heavy
|
||||||
pub fn set_excluded_items(&mut self, excluded_items: Vec<String>, text_messages: &mut Messages) {
|
pub fn set_excluded_items(&mut self, excluded_items: Vec<String>, text_messages: &mut Messages) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
if excluded_items.is_empty() {
|
if excluded_items.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +53,6 @@ impl ExcludedItems {
|
||||||
checked_expressions.push(expression);
|
checked_expressions.push(expression);
|
||||||
}
|
}
|
||||||
self.items = checked_expressions;
|
self.items = checked_expressions;
|
||||||
Common::print_time(start_time, SystemTime::now(), "set_excluded_items");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a specified path is excluded from searching
|
/// Checks whether a specified path is excluded from searching
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
use std::{fs, mem};
|
use std::{fs, mem};
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
|
@ -21,7 +21,7 @@ use humansize::BINARY;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use xxhash_rust::xxh3::Xxh3;
|
use xxhash_rust::xxh3::Xxh3;
|
||||||
|
|
||||||
use crate::common::{open_cache_folder, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, Common};
|
use crate::common::{open_cache_folder, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads};
|
||||||
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -364,11 +364,7 @@ impl DuplicateFinder {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
self.files_with_identical_names = grouped_file_entries;
|
self.files_with_identical_names = grouped_file_entries;
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
|
|
||||||
|
@ -413,7 +409,6 @@ impl DuplicateFinder {
|
||||||
}
|
}
|
||||||
self.calculate_name_stats();
|
self.calculate_name_stats();
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_name");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -459,11 +454,7 @@ impl DuplicateFinder {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
self.files_with_identical_size_names = grouped_file_entries;
|
self.files_with_identical_size_names = grouped_file_entries;
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
|
|
||||||
|
@ -509,7 +500,6 @@ impl DuplicateFinder {
|
||||||
}
|
}
|
||||||
self.calculate_size_name_stats();
|
self.calculate_size_name_stats();
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_size_name");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -559,11 +549,7 @@ impl DuplicateFinder {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
self.files_with_identical_size = grouped_file_entries;
|
self.files_with_identical_size = grouped_file_entries;
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
|
|
||||||
|
@ -586,7 +572,6 @@ impl DuplicateFinder {
|
||||||
self.filter_reference_folders_by_size();
|
self.filter_reference_folders_by_size();
|
||||||
self.calculate_size_stats();
|
self.calculate_size_stats();
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_size");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -723,7 +708,6 @@ impl DuplicateFinder {
|
||||||
progress_sender: Option<&UnboundedSender<ProgressData>>,
|
progress_sender: Option<&UnboundedSender<ProgressData>>,
|
||||||
pre_checked_map: &mut BTreeMap<u64, Vec<FileEntry>>,
|
pre_checked_map: &mut BTreeMap<u64, Vec<FileEntry>>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let check_type = self.hash_type;
|
let check_type = self.hash_type;
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
|
|
||||||
|
@ -791,8 +775,6 @@ impl DuplicateFinder {
|
||||||
|
|
||||||
self.prehash_save_cache_at_exit(loaded_hash_map, &pre_hash_results);
|
self.prehash_save_cache_at_exit(loaded_hash_map, &pre_hash_results);
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_hash - prehash");
|
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +876,6 @@ impl DuplicateFinder {
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
|
|
||||||
let check_type = self.hash_type;
|
let check_type = self.hash_type;
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
||||||
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
||||||
|
@ -958,7 +939,7 @@ impl DuplicateFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,7 +1026,6 @@ impl DuplicateFinder {
|
||||||
/// Function to delete files, from filed before `BTreeMap`
|
/// Function to delete files, from filed before `BTreeMap`
|
||||||
/// Using another function to delete files to avoid duplicates data
|
/// Using another function to delete files to avoid duplicates data
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
if self.delete_method == DeleteMethod::None {
|
if self.delete_method == DeleteMethod::None {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1078,8 +1058,6 @@ impl DuplicateFinder {
|
||||||
panic!("Checking method should never be none.");
|
panic!("Checking method should never be none.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,7 +1124,6 @@ impl DebugPrint for DuplicateFinder {
|
||||||
|
|
||||||
impl SaveResults for DuplicateFinder {
|
impl SaveResults for DuplicateFinder {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -1274,7 +1251,7 @@ impl SaveResults for DuplicateFinder {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1283,7 +1260,6 @@ impl PrintResults for DuplicateFinder {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut number_of_files: u64 = 0;
|
let mut number_of_files: u64 = 0;
|
||||||
let mut number_of_groups: u64 = 0;
|
let mut number_of_groups: u64 = 0;
|
||||||
|
|
||||||
|
@ -1363,7 +1339,6 @@ impl PrintResults for DuplicateFinder {
|
||||||
panic!("Checking Method shouldn't be ever set to None");
|
panic!("Checking Method shouldn't be ever set to None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::BufWriter;
|
use std::io::BufWriter;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use crate::common::Common;
|
|
||||||
use crate::common_dir_traversal::{DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
use crate::common_dir_traversal::{DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -141,17 +141,13 @@ impl EmptyFiles {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
if let Some(empty_files) = grouped_file_entries.get(&()) {
|
if let Some(empty_files) = grouped_file_entries.get(&()) {
|
||||||
self.empty_files = empty_files.clone();
|
self.empty_files = empty_files.clone();
|
||||||
}
|
}
|
||||||
self.information.number_of_empty_files = self.empty_files.len();
|
self.information.number_of_empty_files = self.empty_files.len();
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_name");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -163,8 +159,6 @@ impl EmptyFiles {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
match self.delete_method {
|
match self.delete_method {
|
||||||
DeleteMethod::Delete => {
|
DeleteMethod::Delete => {
|
||||||
for file_entry in &self.empty_files {
|
for file_entry in &self.empty_files {
|
||||||
|
@ -177,8 +171,6 @@ impl EmptyFiles {
|
||||||
//Just do nothing
|
//Just do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +212,6 @@ impl DebugPrint for EmptyFiles {
|
||||||
|
|
||||||
impl SaveResults for EmptyFiles {
|
impl SaveResults for EmptyFiles {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -252,7 +243,7 @@ impl SaveResults for EmptyFiles {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any empty files.").unwrap();
|
write!(writer, "Not found any empty files.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,12 +252,9 @@ impl PrintResults for EmptyFiles {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} empty files.\n", self.information.number_of_empty_files);
|
println!("Found {} empty files.\n", self.information.number_of_empty_files);
|
||||||
for file_entry in &self.empty_files {
|
for file_entry in &self.empty_files {
|
||||||
println!("{}", file_entry.path.display());
|
println!("{}", file_entry.path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufWriter, Write};
|
use std::io::{BufWriter, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use crate::common::Common;
|
|
||||||
use crate::common_dir_traversal::{Collect, DirTraversalBuilder, DirTraversalResult, FolderEmptiness, FolderEntry, ProgressData};
|
use crate::common_dir_traversal::{Collect, DirTraversalBuilder, DirTraversalResult, FolderEmptiness, FolderEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_items::ExcludedItems;
|
use crate::common_items::ExcludedItems;
|
||||||
|
@ -145,11 +145,7 @@ impl EmptyFolder {
|
||||||
DirTraversalResult::SuccessFiles { .. } => {
|
DirTraversalResult::SuccessFiles { .. } => {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders {
|
DirTraversalResult::SuccessFolders { folder_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
folder_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
// We need to set empty folder list
|
// We need to set empty folder list
|
||||||
#[allow(unused_mut)] // Used is later by Windows build
|
#[allow(unused_mut)] // Used is later by Windows build
|
||||||
for (mut name, folder_entry) in folder_entries {
|
for (mut name, folder_entry) in folder_entries {
|
||||||
|
@ -160,7 +156,6 @@ impl EmptyFolder {
|
||||||
|
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_for_empty_folder");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::Stopped => false,
|
DirTraversalResult::Stopped => false,
|
||||||
|
@ -169,7 +164,6 @@ impl EmptyFolder {
|
||||||
|
|
||||||
/// Deletes earlier found empty folders
|
/// Deletes earlier found empty folders
|
||||||
fn delete_empty_folders(&mut self) {
|
fn delete_empty_folders(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
// Folders may be deleted or require too big privileges
|
// Folders may be deleted or require too big privileges
|
||||||
for name in self.empty_folder_list.keys() {
|
for name in self.empty_folder_list.keys() {
|
||||||
match fs::remove_dir_all(name) {
|
match fs::remove_dir_all(name) {
|
||||||
|
@ -177,8 +171,6 @@ impl EmptyFolder {
|
||||||
Err(e) => self.text_messages.warnings.push(format!("Failed to remove folder {}, reason {}", name.display(), e)),
|
Err(e) => self.text_messages.warnings.push(format!("Failed to remove folder {}, reason {}", name.display(), e)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set included dir which needs to be relative, exists etc.
|
/// Set included dir which needs to be relative, exists etc.
|
||||||
|
@ -211,7 +203,6 @@ impl DebugPrint for EmptyFolder {
|
||||||
|
|
||||||
impl SaveResults for EmptyFolder {
|
impl SaveResults for EmptyFolder {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -248,7 +239,7 @@ impl SaveResults for EmptyFolder {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any empty folders.").unwrap();
|
write!(writer, "Not found any empty folders.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@ use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::BufWriter;
|
use std::io::BufWriter;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use crate::common::Common;
|
|
||||||
use crate::common_dir_traversal::{Collect, DirTraversalBuilder, DirTraversalResult, ErrorType, FileEntry, ProgressData};
|
use crate::common_dir_traversal::{Collect, DirTraversalBuilder, DirTraversalResult, ErrorType, FileEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -139,17 +139,12 @@ impl InvalidSymlinks {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
if let Some(((), invalid_symlinks)) = grouped_file_entries.into_iter().next() {
|
if let Some(((), invalid_symlinks)) = grouped_file_entries.into_iter().next() {
|
||||||
self.invalid_symlinks = invalid_symlinks;
|
self.invalid_symlinks = invalid_symlinks;
|
||||||
}
|
}
|
||||||
self.information.number_of_invalid_symlinks = self.invalid_symlinks.len();
|
self.information.number_of_invalid_symlinks = self.invalid_symlinks.len();
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_name");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => unreachable!(),
|
DirTraversalResult::SuccessFolders { .. } => unreachable!(),
|
||||||
|
@ -159,8 +154,6 @@ impl InvalidSymlinks {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
match self.delete_method {
|
match self.delete_method {
|
||||||
DeleteMethod::Delete => {
|
DeleteMethod::Delete => {
|
||||||
for file_entry in &self.invalid_symlinks {
|
for file_entry in &self.invalid_symlinks {
|
||||||
|
@ -173,8 +166,6 @@ impl InvalidSymlinks {
|
||||||
//Just do nothing
|
//Just do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +207,6 @@ impl DebugPrint for InvalidSymlinks {
|
||||||
|
|
||||||
impl SaveResults for InvalidSymlinks {
|
impl SaveResults for InvalidSymlinks {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -258,7 +248,6 @@ impl SaveResults for InvalidSymlinks {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any invalid symlinks.").unwrap();
|
write!(writer, "Not found any invalid symlinks.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +256,6 @@ impl PrintResults for InvalidSymlinks {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} invalid symlinks.\n", self.information.number_of_invalid_symlinks);
|
println!("Found {} invalid symlinks.\n", self.information.number_of_invalid_symlinks);
|
||||||
for file_entry in &self.invalid_symlinks {
|
for file_entry in &self.invalid_symlinks {
|
||||||
println!(
|
println!(
|
||||||
|
@ -280,7 +268,5 @@ impl PrintResults for InvalidSymlinks {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::io::{BufReader, BufWriter};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
use std::{mem, panic};
|
use std::{mem, panic};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
@ -24,7 +24,7 @@ use symphonia::core::meta::MetadataOptions;
|
||||||
use symphonia::core::probe::Hint;
|
use symphonia::core::probe::Hint;
|
||||||
|
|
||||||
use crate::common::{create_crash_message, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, AUDIO_FILES_EXTENSIONS};
|
use crate::common::{create_crash_message, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, AUDIO_FILES_EXTENSIONS};
|
||||||
use crate::common::{open_cache_folder, Common};
|
use crate::common::{open_cache_folder};
|
||||||
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
use crate::common_dir_traversal::{CheckingMethod, DirTraversalBuilder, DirTraversalResult, FileEntry, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -323,18 +323,14 @@ impl SameMusic {
|
||||||
.build()
|
.build()
|
||||||
.run();
|
.run();
|
||||||
match result {
|
match result {
|
||||||
DirTraversalResult::SuccessFiles {
|
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||||
start_time,
|
|
||||||
grouped_file_entries,
|
|
||||||
warnings,
|
|
||||||
} => {
|
|
||||||
if let Some(music_to_check) = grouped_file_entries.get(&()) {
|
if let Some(music_to_check) = grouped_file_entries.get(&()) {
|
||||||
for fe in music_to_check {
|
for fe in music_to_check {
|
||||||
self.music_to_check.insert(fe.path.to_string_lossy().to_string(), fe.to_music_entry());
|
self.music_to_check.insert(fe.path.to_string_lossy().to_string(), fe.to_music_entry());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.text_messages.warnings.extend(warnings);
|
self.text_messages.warnings.extend(warnings);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
DirTraversalResult::SuccessFolders { .. } => {
|
DirTraversalResult::SuccessFolders { .. } => {
|
||||||
|
@ -397,8 +393,6 @@ impl SameMusic {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_fingerprint(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn calculate_fingerprint(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache(false);
|
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache(false);
|
||||||
|
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
|
@ -445,9 +439,7 @@ impl SameMusic {
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
// Just connect loaded results with already calculated
|
// Just connect loaded results with already calculated
|
||||||
for (_name, file_entry) in records_already_cached {
|
vec_file_entry.extend(records_already_cached.into_values());
|
||||||
vec_file_entry.push(file_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.music_entries = vec_file_entry.clone();
|
self.music_entries = vec_file_entry.clone();
|
||||||
|
|
||||||
|
@ -458,14 +450,10 @@ impl SameMusic {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "read_tags");
|
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn read_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache(true);
|
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache(true);
|
||||||
|
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
|
@ -501,9 +489,7 @@ impl SameMusic {
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
// Just connect loaded results with already calculated
|
// Just connect loaded results with already calculated
|
||||||
for (_name, file_entry) in records_already_cached {
|
vec_file_entry.extend(records_already_cached.into_values());
|
||||||
vec_file_entry.push(file_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.music_entries = vec_file_entry.clone();
|
self.music_entries = vec_file_entry.clone();
|
||||||
|
|
||||||
|
@ -514,8 +500,6 @@ impl SameMusic {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "read_tags");
|
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn read_single_file_tag(&self, path: &str, mut music_entry: MusicEntry) -> Option<MusicEntry> {
|
fn read_single_file_tag(&self, path: &str, mut music_entry: MusicEntry) -> Option<MusicEntry> {
|
||||||
|
@ -616,7 +600,6 @@ impl SameMusic {
|
||||||
|
|
||||||
fn check_for_duplicate_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn check_for_duplicate_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
assert_ne!(MusicSimilarity::NONE, self.music_similarity, "This can't be none");
|
assert_ne!(MusicSimilarity::NONE, self.music_similarity, "This can't be none");
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
||||||
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
||||||
|
@ -717,8 +700,6 @@ impl SameMusic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_for_duplicate_tags");
|
|
||||||
|
|
||||||
// Clear unused data
|
// Clear unused data
|
||||||
self.music_entries.clear();
|
self.music_entries.clear();
|
||||||
|
|
||||||
|
@ -794,7 +775,7 @@ impl SameMusic {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
// TODO
|
// TODO
|
||||||
// match self.delete_method {
|
// match self.delete_method {
|
||||||
// DeleteMethod::Delete => {
|
// DeleteMethod::Delete => {
|
||||||
|
@ -808,8 +789,6 @@ impl SameMusic {
|
||||||
// //Just do nothing
|
// //Just do nothing
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,7 +968,6 @@ impl DebugPrint for SameMusic {
|
||||||
|
|
||||||
impl SaveResults for SameMusic {
|
impl SaveResults for SameMusic {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -1021,7 +999,7 @@ impl SaveResults for SameMusic {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any empty files.").unwrap();
|
write!(writer, "Not found any empty files.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1008,6 @@ impl PrintResults for SameMusic {
|
||||||
/// Print information's about duplicated entries
|
/// Print information's about duplicated entries
|
||||||
/// Only needed for CLI
|
/// Only needed for CLI
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} similar music files.\n", self.duplicated_music_entries.len());
|
println!("Found {} similar music files.\n", self.duplicated_music_entries.len());
|
||||||
for vec_file_entry in &self.duplicated_music_entries {
|
for vec_file_entry in &self.duplicated_music_entries {
|
||||||
for file_entry in vec_file_entry {
|
for file_entry in vec_file_entry {
|
||||||
|
@ -1047,8 +1024,6 @@ impl PrintResults for SameMusic {
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::common::get_dynamic_image_from_heic;
|
use crate::common::get_dynamic_image_from_heic;
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
check_folder_children, create_crash_message, get_dynamic_image_from_raw_image, get_number_of_threads, open_cache_folder, prepare_thread_handler_common,
|
check_folder_children, create_crash_message, get_dynamic_image_from_raw_image, get_number_of_threads, open_cache_folder, prepare_thread_handler_common,
|
||||||
send_info_and_wait_for_ending_all_threads, Common, HEIC_EXTENSIONS, IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS, RAW_IMAGE_EXTENSIONS,
|
send_info_and_wait_for_ending_all_threads, HEIC_EXTENSIONS, IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS, RAW_IMAGE_EXTENSIONS,
|
||||||
};
|
};
|
||||||
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
|
@ -275,7 +275,6 @@ impl SimilarImages {
|
||||||
/// Function to check if folder are empty.
|
/// Function to check if folder are empty.
|
||||||
/// Parameter `initial_checking` for second check before deleting to be sure that checked folder is still empty
|
/// Parameter `initial_checking` for second check before deleting to be sure that checked folder is still empty
|
||||||
fn check_for_similar_images(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn check_for_similar_images(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
|
|
||||||
if !self.allowed_extensions.using_custom_extensions() {
|
if !self.allowed_extensions.using_custom_extensions() {
|
||||||
|
@ -355,7 +354,7 @@ impl SimilarImages {
|
||||||
}
|
}
|
||||||
|
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_for_similar_images");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,13 +427,8 @@ impl SimilarImages {
|
||||||
// - Join all hashes and save it to file
|
// - Join all hashes and save it to file
|
||||||
|
|
||||||
fn hash_images(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn hash_images(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.hash_images_load_cache();
|
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.hash_images_load_cache();
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_images - reading data from cache and preparing them");
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
||||||
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
let atomic_counter = Arc::new(AtomicUsize::new(0));
|
||||||
|
@ -465,11 +459,8 @@ impl SimilarImages {
|
||||||
|
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_images - reading data from files in parallel");
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
// Just connect loaded results with already calculated hashes
|
// Just connect loaded results with already calculated hashes
|
||||||
for (_name, file_entry) in records_already_cached {
|
for file_entry in records_already_cached.into_values() {
|
||||||
vec_file_entry.push((file_entry.clone(), file_entry.hash));
|
vec_file_entry.push((file_entry.clone(), file_entry.hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +493,6 @@ impl SimilarImages {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_images - saving data to files");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn collect_image_file_entry(&self, mut file_entry: FileEntry) -> (FileEntry, ImHash) {
|
fn collect_image_file_entry(&self, mut file_entry: FileEntry) -> (FileEntry, ImHash) {
|
||||||
|
@ -813,7 +803,6 @@ impl SimilarImages {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
let tolerance = self.similarity;
|
let tolerance = self.similarity;
|
||||||
|
|
||||||
// Results
|
// Results
|
||||||
|
@ -874,8 +863,6 @@ impl SimilarImages {
|
||||||
|
|
||||||
self.check_for_reference_folders();
|
self.check_for_reference_folders();
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_images - selecting data from HashMap");
|
|
||||||
|
|
||||||
if self.use_reference_folders {
|
if self.use_reference_folders {
|
||||||
for (_fe, vector) in &self.similar_referenced_vectors {
|
for (_fe, vector) in &self.similar_referenced_vectors {
|
||||||
self.information.number_of_duplicates += vector.len();
|
self.information.number_of_duplicates += vector.len();
|
||||||
|
@ -1077,7 +1064,6 @@ impl DebugPrint for SimilarImages {
|
||||||
|
|
||||||
impl SaveResults for SimilarImages {
|
impl SaveResults for SimilarImages {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -1123,7 +1109,6 @@ impl SaveResults for SimilarImages {
|
||||||
write!(writer, "Not found any similar images.").unwrap();
|
write!(writer, "Not found any similar images.").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::mem;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use ffmpeg_cmdline_utils::FfmpegErrorKind::FfmpegNotFound;
|
use ffmpeg_cmdline_utils::FfmpegErrorKind::FfmpegNotFound;
|
||||||
|
@ -19,7 +19,7 @@ use vid_dup_finder_lib::HashCreationErrorKind::DetermineVideo;
|
||||||
use vid_dup_finder_lib::{NormalizedTolerance, VideoHash};
|
use vid_dup_finder_lib::{NormalizedTolerance, VideoHash};
|
||||||
|
|
||||||
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, VIDEO_FILES_EXTENSIONS};
|
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, VIDEO_FILES_EXTENSIONS};
|
||||||
use crate::common::{open_cache_folder, Common};
|
use crate::common::{open_cache_folder};
|
||||||
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_extensions::Extensions;
|
use crate::common_extensions::Extensions;
|
||||||
|
@ -242,7 +242,6 @@ impl SimilarVideos {
|
||||||
/// Function to check if folder are empty.
|
/// Function to check if folder are empty.
|
||||||
/// Parameter `initial_checking` for second check before deleting to be sure that checked folder is still empty
|
/// Parameter `initial_checking` for second check before deleting to be sure that checked folder is still empty
|
||||||
fn check_for_similar_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn check_for_similar_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
|
|
||||||
if !self.allowed_extensions.using_custom_extensions() {
|
if !self.allowed_extensions.using_custom_extensions() {
|
||||||
|
@ -319,7 +318,7 @@ impl SimilarVideos {
|
||||||
}
|
}
|
||||||
|
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_for_similar_videos");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,13 +384,8 @@ impl SimilarVideos {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sort_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn sort_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache_at_start();
|
let (loaded_hash_map, records_already_cached, non_cached_files_to_check) = self.load_cache_at_start();
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_videos - reading data from cache and preparing them");
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
let check_was_stopped = AtomicBool::new(false); // Used for breaking from GUI and ending check thread
|
||||||
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
let progress_thread_run = Arc::new(AtomicBool::new(true));
|
||||||
|
|
||||||
|
@ -435,13 +429,8 @@ impl SimilarVideos {
|
||||||
|
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_videos - reading data from files in parallel");
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
// Just connect loaded results with already calculated hashes
|
// Just connect loaded results with already calculated hashes
|
||||||
for (_name, file_entry) in records_already_cached {
|
vec_file_entry.extend(records_already_cached.into_values());
|
||||||
vec_file_entry.push(file_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut hashmap_with_file_entries: HashMap<String, FileEntry> = Default::default();
|
let mut hashmap_with_file_entries: HashMap<String, FileEntry> = Default::default();
|
||||||
let mut vector_of_hashes: Vec<VideoHash> = Vec::new();
|
let mut vector_of_hashes: Vec<VideoHash> = Vec::new();
|
||||||
|
@ -469,9 +458,6 @@ impl SimilarVideos {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_videos - saving data to files");
|
|
||||||
let hash_map_modification = SystemTime::now();
|
|
||||||
|
|
||||||
self.match_groups_of_videos(vector_of_hashes, &hashmap_with_file_entries);
|
self.match_groups_of_videos(vector_of_hashes, &hashmap_with_file_entries);
|
||||||
self.remove_from_reference_folders();
|
self.remove_from_reference_folders();
|
||||||
|
|
||||||
|
@ -487,8 +473,6 @@ impl SimilarVideos {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_videos - selecting data from BtreeMap");
|
|
||||||
|
|
||||||
// Clean unused data
|
// Clean unused data
|
||||||
self.videos_hashes = Default::default();
|
self.videos_hashes = Default::default();
|
||||||
self.videos_to_check = Default::default();
|
self.videos_to_check = Default::default();
|
||||||
|
@ -590,7 +574,6 @@ impl DebugPrint for SimilarVideos {
|
||||||
|
|
||||||
impl SaveResults for SimilarVideos {
|
impl SaveResults for SimilarVideos {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -628,7 +611,6 @@ impl SaveResults for SimilarVideos {
|
||||||
write!(writer, "Not found any similar videos.").unwrap();
|
write!(writer, "Not found any similar videos.").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ use std::io::BufWriter;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, Common};
|
use crate::common::{check_folder_children, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads};
|
||||||
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_dir, get_lowercase_name, get_modified_time, CheckingMethod, ProgressData};
|
||||||
use crate::common_directory::Directories;
|
use crate::common_directory::Directories;
|
||||||
use crate::common_items::ExcludedItems;
|
use crate::common_items::ExcludedItems;
|
||||||
|
@ -143,7 +143,6 @@ impl Temporary {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
fn check_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let mut folders_to_check: Vec<PathBuf> = 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
|
let mut folders_to_check: Vec<PathBuf> = 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
|
||||||
|
|
||||||
// Add root folders for finding
|
// Add root folders for finding
|
||||||
|
@ -214,7 +213,6 @@ impl Temporary {
|
||||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||||
self.information.number_of_temporary_files = self.temporary_files.len();
|
self.information.number_of_temporary_files = self.temporary_files.len();
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "check_files_size");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
pub fn get_file_entry(
|
pub fn get_file_entry(
|
||||||
|
@ -248,8 +246,6 @@ impl Temporary {
|
||||||
|
|
||||||
/// Function to delete files, from filed Vector
|
/// Function to delete files, from filed Vector
|
||||||
fn delete_files(&mut self) {
|
fn delete_files(&mut self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
|
|
||||||
match self.delete_method {
|
match self.delete_method {
|
||||||
DeleteMethod::Delete => {
|
DeleteMethod::Delete => {
|
||||||
for file_entry in &self.temporary_files {
|
for file_entry in &self.temporary_files {
|
||||||
|
@ -262,8 +258,6 @@ impl Temporary {
|
||||||
//Just do nothing
|
//Just do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "delete_files");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +298,6 @@ impl DebugPrint for Temporary {
|
||||||
|
|
||||||
impl SaveResults for Temporary {
|
impl SaveResults for Temporary {
|
||||||
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
fn save_results_to_file(&mut self, file_name: &str) -> bool {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
let file_name: String = match file_name {
|
let file_name: String = match file_name {
|
||||||
"" => "results.txt".to_string(),
|
"" => "results.txt".to_string(),
|
||||||
k => k.to_string(),
|
k => k.to_string(),
|
||||||
|
@ -336,19 +329,16 @@ impl SaveResults for Temporary {
|
||||||
} else {
|
} else {
|
||||||
write!(writer, "Not found any temporary files.").unwrap();
|
write!(writer, "Not found any temporary files.").unwrap();
|
||||||
}
|
}
|
||||||
Common::print_time(start_time, SystemTime::now(), "save_results_to_file");
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrintResults for Temporary {
|
impl PrintResults for Temporary {
|
||||||
fn print_results(&self) {
|
fn print_results(&self) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
|
||||||
println!("Found {} temporary files.\n", self.information.number_of_temporary_files);
|
println!("Found {} temporary files.\n", self.information.number_of_temporary_files);
|
||||||
for file_entry in &self.temporary_files {
|
for file_entry in &self.temporary_files {
|
||||||
println!("{}", file_entry.path.display());
|
println!("{}", file_entry.path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::print_time(start_time, SystemTime::now(), "print_entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue