mirror of https://github.com/qarmin/czkawka.git
Use max line length 180 instead 250 (#515)
This was a little too big value. I don't like too much too small values, because code looks ugly.pull/524/head
parent
878550446d
commit
5db5d17afb
|
@ -1,3 +1,3 @@
|
|||
newline_style = "Unix"
|
||||
max_width = 250
|
||||
max_width = 180
|
||||
remove_nested_parens = true
|
||||
|
|
|
@ -217,19 +217,37 @@ pub enum Commands {
|
|||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Directories {
|
||||
#[structopt(short, long, parse(from_os_str), required = true, help = "Directorie(s) to search", long_help = "List of directorie(s) which will be searched(absolute path)")]
|
||||
#[structopt(
|
||||
short,
|
||||
long,
|
||||
parse(from_os_str),
|
||||
required = true,
|
||||
help = "Directorie(s) to search",
|
||||
long_help = "List of directorie(s) which will be searched(absolute path)"
|
||||
)]
|
||||
pub directories: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct ExcludedDirectories {
|
||||
#[structopt(short, long, parse(from_os_str), help = "Excluded directorie(s)", long_help = "List of directorie(s) which will be excluded from search(absolute path)")]
|
||||
#[structopt(
|
||||
short,
|
||||
long,
|
||||
parse(from_os_str),
|
||||
help = "Excluded directorie(s)",
|
||||
long_help = "List of directorie(s) which will be excluded from search(absolute path)"
|
||||
)]
|
||||
pub excluded_directories: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct ExcludedItems {
|
||||
#[structopt(short = "E", long, help = "Excluded item(s)", long_help = "List of excluded item(s) which contains * wildcard(may be slow, so use -e where possible)")]
|
||||
#[structopt(
|
||||
short = "E",
|
||||
long,
|
||||
help = "Excluded item(s)",
|
||||
long_help = "List of excluded item(s) which contains * wildcard(may be slow, so use -e where possible)"
|
||||
)]
|
||||
pub excluded_items: Vec<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,10 @@ impl BigFile {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -185,14 +188,20 @@ impl BigFile {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -217,7 +226,10 @@ impl BigFile {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +251,10 @@ impl BigFile {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -430,7 +445,11 @@ impl SaveResults for BigFile {
|
|||
impl PrintResults for BigFile {
|
||||
fn print_results(&self) {
|
||||
let start_time: SystemTime = SystemTime::now();
|
||||
println!("Found {} files which take {}:", self.information.number_of_real_files, self.information.taken_space.file_size(options::BINARY).unwrap());
|
||||
println!(
|
||||
"Found {} files which take {}:",
|
||||
self.information.number_of_real_files,
|
||||
self.information.taken_space.file_size(options::BINARY).unwrap()
|
||||
);
|
||||
for (size, vector) in self.big_files.iter().rev() {
|
||||
// TODO Align all to same width
|
||||
for entry in vector {
|
||||
|
|
|
@ -215,7 +215,10 @@ impl BrokenFiles {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -225,14 +228,20 @@ impl BrokenFiles {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -257,7 +266,10 @@ impl BrokenFiles {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +295,10 @@ impl BrokenFiles {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -466,7 +481,10 @@ impl BrokenFiles {
|
|||
vec_file_entry.push(file_entry.clone());
|
||||
}
|
||||
|
||||
self.broken_files = vec_file_entry.iter().filter_map(|f| if f.error_string.is_empty() { None } else { Some(f.clone()) }).collect();
|
||||
self.broken_files = vec_file_entry
|
||||
.iter()
|
||||
.filter_map(|f| if f.error_string.is_empty() { None } else { Some(f.clone()) })
|
||||
.collect();
|
||||
|
||||
if self.use_cache {
|
||||
// Must save all results to file, old loaded from file with all currently counted results
|
||||
|
@ -619,7 +637,9 @@ fn save_cache_to_file(hashmap_file_entry: &BTreeMap<String, FileEntry>, text_mes
|
|||
let file_handler = match OpenOptions::new().truncate(true).write(true).create(true).open(&cache_file) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages.messages.push(format!("Cannot create or open cache file {}, reason {}", cache_file.display(), e));
|
||||
text_messages
|
||||
.messages
|
||||
.push(format!("Cannot create or open cache file {}, reason {}", cache_file.display(), e));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -628,10 +648,18 @@ fn save_cache_to_file(hashmap_file_entry: &BTreeMap<String, FileEntry>, text_mes
|
|||
for file_entry in hashmap_file_entry.values() {
|
||||
// Only save to cache files which have more than 1KB
|
||||
if file_entry.size > 1024 {
|
||||
let string: String = format!("{}//{}//{}//{}", file_entry.path.display(), file_entry.size, file_entry.modified_date, file_entry.error_string);
|
||||
let string: String = format!(
|
||||
"{}//{}//{}//{}",
|
||||
file_entry.path.display(),
|
||||
file_entry.size,
|
||||
file_entry.modified_date,
|
||||
file_entry.error_string
|
||||
);
|
||||
|
||||
if let Err(e) = writeln!(writer, "{}", string) {
|
||||
text_messages.messages.push(format!("Failed to save some data to cache file {}, reason {}", cache_file.display(), e));
|
||||
text_messages
|
||||
.messages
|
||||
.push(format!("Failed to save some data to cache file {}, reason {}", cache_file.display(), e));
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
@ -661,13 +689,17 @@ fn load_cache_from_file(text_messages: &mut Messages) -> Option<BTreeMap<String,
|
|||
let line = match line {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages.warnings.push(format!("Failed to load line number {} from cache file {}, reason {}", index + 1, cache_file.display(), e));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Failed to load line number {} from cache file {}, reason {}", index + 1, cache_file.display(), e));
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let uuu = line.split("//").collect::<Vec<&str>>();
|
||||
if uuu.len() != 4 {
|
||||
text_messages.warnings.push(format!("Found invalid data in line {} - ({}) in cache file {}", index + 1, line, cache_file.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid data in line {} - ({}) in cache file {}", index + 1, line, cache_file.display()));
|
||||
continue;
|
||||
}
|
||||
// Don't load cache data if destination file not exists
|
||||
|
@ -679,18 +711,26 @@ fn load_cache_from_file(text_messages: &mut Messages) -> Option<BTreeMap<String,
|
|||
size: match uuu[1].parse::<u64>() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid size value in line {} - ({}) in cache file {}, reason {}", index + 1, line, cache_file.display(), e));
|
||||
text_messages.warnings.push(format!(
|
||||
"Found invalid size value in line {} - ({}) in cache file {}, reason {}",
|
||||
index + 1,
|
||||
line,
|
||||
cache_file.display(),
|
||||
e
|
||||
));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
modified_date: match uuu[2].parse::<u64>() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid modified date value in line {} - ({}) in cache file {}, reason {}", index + 1, line, cache_file.display(), e));
|
||||
text_messages.warnings.push(format!(
|
||||
"Found invalid modified date value in line {} - ({}) in cache file {}, reason {}",
|
||||
index + 1,
|
||||
line,
|
||||
cache_file.display(),
|
||||
e
|
||||
));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -12,7 +12,11 @@ impl Common {
|
|||
#[allow(unused_variables)]
|
||||
pub fn print_time(start_time: SystemTime, end_time: SystemTime, function_name: String) {
|
||||
#[cfg(debug_assertions)]
|
||||
println!("Execution of function \"{}\" took {:?}", function_name, end_time.duration_since(start_time).expect("Time cannot go reverse."));
|
||||
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> {
|
||||
|
|
|
@ -29,34 +29,47 @@ impl Directories {
|
|||
let mut checked_directories: Vec<PathBuf> = Vec::new();
|
||||
for directory in directories {
|
||||
if directory.to_string_lossy().contains('*') {
|
||||
text_messages.warnings.push(format!("Included Directory Warning: Wildcards in path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Included Directory Warning: Wildcards in path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "windows"))]
|
||||
if directory.is_relative() {
|
||||
text_messages.warnings.push(format!("Included Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Included Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
#[cfg(target_family = "windows")]
|
||||
if directory.is_relative() && !directory.starts_with("\\") {
|
||||
text_messages.warnings.push(format!("Included Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Included Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if !directory.exists() {
|
||||
text_messages.warnings.push(format!("Included Directory Warning: Provided folder path must exits, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Included Directory Warning: Provided folder path must exits, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
if !directory.is_dir() {
|
||||
text_messages.warnings.push(format!("Included Directory Warning: Provided path must point at the directory, ignoring {}", directory.display()));
|
||||
text_messages.warnings.push(format!(
|
||||
"Included Directory Warning: Provided path must point at the directory, ignoring {}",
|
||||
directory.display()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
checked_directories.push(directory);
|
||||
}
|
||||
|
||||
if checked_directories.is_empty() {
|
||||
text_messages.errors.push("Included Directory ERROR: Not found even one correct path to included which is required.".to_string());
|
||||
text_messages
|
||||
.errors
|
||||
.push("Included Directory ERROR: Not found even one correct path to included which is required.".to_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -79,21 +92,29 @@ impl Directories {
|
|||
for directory in directories {
|
||||
let directory_as_string = directory.to_string_lossy();
|
||||
if directory_as_string == "/" {
|
||||
text_messages.errors.push("Excluded Directory ERROR: Excluding / is pointless, because it means that no files will be scanned.".to_string());
|
||||
text_messages
|
||||
.errors
|
||||
.push("Excluded Directory ERROR: Excluding / is pointless, because it means that no files will be scanned.".to_string());
|
||||
break;
|
||||
}
|
||||
if directory_as_string.contains('*') {
|
||||
text_messages.warnings.push(format!("Excluded Directory Warning: Wildcards in path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Excluded Directory Warning: Wildcards in path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
#[cfg(not(target_family = "windows"))]
|
||||
if directory.is_relative() {
|
||||
text_messages.warnings.push(format!("Excluded Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Excluded Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
#[cfg(target_family = "windows")]
|
||||
if directory.is_relative() && !directory.starts_with("\\") {
|
||||
text_messages.warnings.push(format!("Excluded Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Excluded Directory Warning: Relative path are not supported, ignoring {}", directory.display()));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -102,7 +123,10 @@ impl Directories {
|
|||
continue;
|
||||
}
|
||||
if !directory.is_dir() {
|
||||
text_messages.warnings.push(format!("Excluded Directory Warning: Provided path must point at the directory, ignoring {}", directory.display()));
|
||||
text_messages.warnings.push(format!(
|
||||
"Excluded Directory Warning: Provided path must point at the directory, ignoring {}",
|
||||
directory.display()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
checked_directories.push(directory);
|
||||
|
@ -228,7 +252,9 @@ impl Directories {
|
|||
self.excluded_directories = optimized_excluded;
|
||||
|
||||
if self.included_directories.is_empty() {
|
||||
text_messages.errors.push("Optimize Directories ERROR: Excluded directories overlaps all included directories.".to_string());
|
||||
text_messages
|
||||
.errors
|
||||
.push("Optimize Directories ERROR: Excluded directories overlaps all included directories.".to_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,9 @@ impl Extensions {
|
|||
}
|
||||
|
||||
if extension[1..].contains(' ') {
|
||||
text_messages.warnings.push(format!("{} is not valid extension because contains empty space inside", extension));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("{} is not valid extension because contains empty space inside", extension));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -50,7 +52,9 @@ impl Extensions {
|
|||
}
|
||||
|
||||
if self.file_extensions.is_empty() {
|
||||
text_messages.messages.push("No valid extensions were provided, so allowing all extensions by default.".to_string());
|
||||
text_messages
|
||||
.messages
|
||||
.push("No valid extensions were provided, so allowing all extensions by default.".to_string());
|
||||
}
|
||||
Common::print_time(start_time, SystemTime::now(), "set_allowed_extensions".to_string());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ impl ExcludedItems {
|
|||
continue;
|
||||
}
|
||||
if !expression.contains('*') {
|
||||
text_messages.warnings.push("Excluded Items Warning: Wildcard * is required in expression, ignoring ".to_string() + expression.as_str());
|
||||
text_messages
|
||||
.warnings
|
||||
.push("Excluded Items Warning: Wildcard * is required in expression, ignoring ".to_string() + expression.as_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -347,7 +347,10 @@ impl DuplicateFinder {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -357,14 +360,20 @@ impl DuplicateFinder {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -389,7 +398,10 @@ impl DuplicateFinder {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +424,10 @@ impl DuplicateFinder {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -535,7 +550,10 @@ impl DuplicateFinder {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -545,14 +563,20 @@ impl DuplicateFinder {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -577,7 +601,10 @@ impl DuplicateFinder {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +628,10 @@ impl DuplicateFinder {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -1100,8 +1130,16 @@ impl DebugPrint for DuplicateFinder {
|
|||
"Number of duplicated files by name(in groups) - {} ({})",
|
||||
self.information.number_of_duplicated_files_by_name, self.information.number_of_groups_by_name
|
||||
);
|
||||
println!("Lost space by size - {} ({} bytes)", self.information.lost_space_by_size.file_size(options::BINARY).unwrap(), self.information.lost_space_by_size);
|
||||
println!("Lost space by hash - {} ({} bytes)", self.information.lost_space_by_hash.file_size(options::BINARY).unwrap(), self.information.lost_space_by_hash);
|
||||
println!(
|
||||
"Lost space by size - {} ({} bytes)",
|
||||
self.information.lost_space_by_size.file_size(options::BINARY).unwrap(),
|
||||
self.information.lost_space_by_size
|
||||
);
|
||||
println!(
|
||||
"Lost space by hash - {} ({} bytes)",
|
||||
self.information.lost_space_by_hash.file_size(options::BINARY).unwrap(),
|
||||
self.information.lost_space_by_hash
|
||||
);
|
||||
println!(
|
||||
"Gained space by removing duplicated entries - {} ({} bytes)",
|
||||
self.information.gained_space.file_size(options::BINARY).unwrap(),
|
||||
|
@ -1151,7 +1189,11 @@ impl SaveResults for DuplicateFinder {
|
|||
match self.check_method {
|
||||
CheckingMethod::Name => {
|
||||
if !self.files_with_identical_names.is_empty() {
|
||||
writeln!(writer, "-------------------------------------------------Files with same names-------------------------------------------------").unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"-------------------------------------------------Files with same names-------------------------------------------------"
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"Found {} files in {} groups with same name(may have different content)",
|
||||
|
@ -1171,7 +1213,11 @@ impl SaveResults for DuplicateFinder {
|
|||
}
|
||||
CheckingMethod::Size => {
|
||||
if !self.files_with_identical_size.is_empty() {
|
||||
writeln!(writer, "-------------------------------------------------Files with same size-------------------------------------------------").unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"-------------------------------------------------Files with same size-------------------------------------------------"
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"Found {} duplicated files which in {} groups which takes {}.",
|
||||
|
@ -1192,7 +1238,11 @@ impl SaveResults for DuplicateFinder {
|
|||
}
|
||||
CheckingMethod::Hash => {
|
||||
if !self.files_with_identical_hashes.is_empty() {
|
||||
writeln!(writer, "-------------------------------------------------Files with same hashes-------------------------------------------------").unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"-------------------------------------------------Files with same hashes-------------------------------------------------"
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"Found {} duplicated files which in {} groups which takes {}.",
|
||||
|
@ -1406,7 +1456,9 @@ pub fn save_hashes_to_file(hashmap: &BTreeMap<String, FileEntry>, text_messages:
|
|||
let file_handler = match OpenOptions::new().truncate(true).write(true).create(true).open(&cache_file) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages.messages.push(format!("Cannot create or open cache file {}, reason {}", cache_file.display(), e));
|
||||
text_messages
|
||||
.messages
|
||||
.push(format!("Cannot create or open cache file {}, reason {}", cache_file.display(), e));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -1418,7 +1470,9 @@ pub fn save_hashes_to_file(hashmap: &BTreeMap<String, FileEntry>, text_messages:
|
|||
let string: String = format!("{}//{}//{}//{}", file_entry.path.display(), file_entry.size, file_entry.modified_date, file_entry.hash);
|
||||
|
||||
if let Err(e) = writeln!(writer, "{}", string) {
|
||||
text_messages.messages.push(format!("Failed to save some data to cache file {}, reason {}", cache_file.display(), e));
|
||||
text_messages
|
||||
.messages
|
||||
.push(format!("Failed to save some data to cache file {}, reason {}", cache_file.display(), e));
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
@ -1480,15 +1534,20 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
|
|||
let line = match line {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages.warnings.push(format!("Failed to load line number {} from cache file {}, reason {}", index + 1, cache_file.display(), e));
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Failed to load line number {} from cache file {}, reason {}", index + 1, cache_file.display(), e));
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let uuu = line.split("//").collect::<Vec<&str>>();
|
||||
if uuu.len() != 4 {
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid data(too much or too low amount of data) in line {} - ({}) in cache file {}", index + 1, line, cache_file.display()));
|
||||
text_messages.warnings.push(format!(
|
||||
"Found invalid data(too much or too low amount of data) in line {} - ({}) in cache file {}",
|
||||
index + 1,
|
||||
line,
|
||||
cache_file.display()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
// Don't load cache data if destination file not exists
|
||||
|
@ -1498,18 +1557,26 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
|
|||
size: match uuu[1].parse::<u64>() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid size value in line {} - ({}) in cache file {}, reason {}", index + 1, line, cache_file.display(), e));
|
||||
text_messages.warnings.push(format!(
|
||||
"Found invalid size value in line {} - ({}) in cache file {}, reason {}",
|
||||
index + 1,
|
||||
line,
|
||||
cache_file.display(),
|
||||
e
|
||||
));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
modified_date: match uuu[2].parse::<u64>() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
text_messages
|
||||
.warnings
|
||||
.push(format!("Found invalid modified date value in line {} - ({}) in cache file {}, reason {}", index + 1, line, cache_file.display(), e));
|
||||
text_messages.warnings.push(format!(
|
||||
"Found invalid modified date value in line {} - ({}) in cache file {}, reason {}",
|
||||
index + 1,
|
||||
line,
|
||||
cache_file.display(),
|
||||
e
|
||||
));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -186,7 +186,10 @@ impl EmptyFiles {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -196,14 +199,20 @@ impl EmptyFiles {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -228,7 +237,10 @@ impl EmptyFiles {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +262,10 @@ impl EmptyFiles {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
|
|
@ -201,9 +201,10 @@ impl EmptyFolder {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
self.text_messages
|
||||
.warnings
|
||||
.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
self.text_messages.warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -213,18 +214,20 @@ impl EmptyFolder {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
self.text_messages
|
||||
.warnings
|
||||
.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
self.text_messages.warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
self.text_messages
|
||||
.warnings
|
||||
.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
self.text_messages.warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -245,16 +248,18 @@ impl EmptyFolder {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
self.text_messages
|
||||
.warnings
|
||||
.push(fl!("core_folder_modified_before_epoch", generate_translation_hashmap(vec![("name", current_folder.display().to_string())])));
|
||||
self.text_messages.warnings.push(fl!(
|
||||
"core_folder_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_folder.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
self.text_messages
|
||||
.warnings
|
||||
.push(fl!("core_folder_no_modification_date", generate_translation_hashmap(vec![("name", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
self.text_messages.warnings.push(fl!(
|
||||
"core_folder_no_modification_date",
|
||||
generate_translation_hashmap(vec![("name", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -356,13 +361,21 @@ impl SaveResults for EmptyFolder {
|
|||
};
|
||||
let mut writer = BufWriter::new(file_handler);
|
||||
|
||||
if let Err(e) = writeln!(writer, "Results of searching {:?} with excluded directories {:?}", self.directories.included_directories, self.directories.excluded_directories) {
|
||||
if let Err(e) = writeln!(
|
||||
writer,
|
||||
"Results of searching {:?} with excluded directories {:?}",
|
||||
self.directories.included_directories, self.directories.excluded_directories
|
||||
) {
|
||||
self.text_messages.errors.push(format!("Failed to save results to file {}, reason {}", file_name, e));
|
||||
return false;
|
||||
}
|
||||
|
||||
if !self.empty_folder_list.is_empty() {
|
||||
writeln!(writer, "-------------------------------------------------Empty folder list-------------------------------------------------").unwrap();
|
||||
writeln!(
|
||||
writer,
|
||||
"-------------------------------------------------Empty folder list-------------------------------------------------"
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(writer, "Found {} empty folders", self.information.number_of_empty_folders).unwrap();
|
||||
for name in self.empty_folder_list.keys() {
|
||||
writeln!(writer, "{}", name.display()).unwrap();
|
||||
|
|
|
@ -196,7 +196,10 @@ impl InvalidSymlinks {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -206,14 +209,20 @@ impl InvalidSymlinks {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -240,7 +249,10 @@ impl InvalidSymlinks {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +311,10 @@ impl InvalidSymlinks {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
|
|
@ -257,7 +257,10 @@ impl SameMusic {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -267,14 +270,20 @@ impl SameMusic {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -299,7 +308,10 @@ impl SameMusic {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +335,10 @@ impl SameMusic {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
|
|
@ -245,8 +245,11 @@ impl SimilarImages {
|
|||
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
|
||||
|
||||
self.allowed_extensions
|
||||
.extend_allowed_extensions(&[".jpg", ".jpeg", ".png" /*, ".bmp"*/, ".tiff", ".tif", ".tga", ".ff" /*, ".gif"*/, ".jif", ".jfi" /*, ".webp"*/]); // webp cannot be seen in preview, gif needs to be enabled after releasing image crate 0.24.0, bmp needs to be fixed in image crate
|
||||
self.allowed_extensions.extend_allowed_extensions(&[
|
||||
".jpg", ".jpeg", ".png", /*, ".bmp"*/
|
||||
".tiff", ".tif", ".tga", ".ff", /*, ".gif"*/
|
||||
".jif", ".jfi", /*, ".webp"*/
|
||||
]); // webp cannot be seen in preview, gif needs to be enabled after releasing image crate 0.24.0, bmp needs to be fixed in image crate
|
||||
|
||||
// Add root folders for finding
|
||||
for id in &self.directories.included_directories {
|
||||
|
@ -300,7 +303,10 @@ impl SimilarImages {
|
|||
let read_dir = match fs::read_dir(¤t_folder) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_open_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_open_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
return (dir_result, warnings, fe_result);
|
||||
}
|
||||
};
|
||||
|
@ -310,14 +316,20 @@ impl SimilarImages {
|
|||
let entry_data = match entry {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_entry_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_entry_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
let metadata: Metadata = match entry_data.metadata() {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
warnings.push(fl!("core_cannot_read_metadata_dir", generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_cannot_read_metadata_dir",
|
||||
generate_translation_hashmap(vec![("dir", current_folder.display().to_string()), ("reason", e.to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
};
|
||||
|
@ -342,7 +354,10 @@ impl SimilarImages {
|
|||
let file_name_lowercase: String = match entry_data.file_name().into_string() {
|
||||
Ok(t) => t,
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_not_utf8_name", generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_not_utf8_name",
|
||||
generate_translation_hashmap(vec![("name", entry_data.path().display().to_string())])
|
||||
));
|
||||
continue 'dir;
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +382,10 @@ impl SimilarImages {
|
|||
Ok(t) => match t.duration_since(UNIX_EPOCH) {
|
||||
Ok(d) => d.as_secs(),
|
||||
Err(_inspected) => {
|
||||
warnings.push(fl!("core_file_modified_before_epoch", generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])));
|
||||
warnings.push(fl!(
|
||||
"core_file_modified_before_epoch",
|
||||
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
|
||||
));
|
||||
0
|
||||
}
|
||||
},
|
||||
|
@ -451,7 +469,11 @@ impl SimilarImages {
|
|||
mem::swap(&mut self.images_to_check, &mut non_cached_files_to_check);
|
||||
}
|
||||
|
||||
Common::print_time(hash_map_modification, SystemTime::now(), "sort_images - reading data from cache and preparing them".to_string());
|
||||
Common::print_time(
|
||||
hash_map_modification,
|
||||
SystemTime::now(),
|
||||
"sort_images - reading data from cache and preparing them".to_string(),
|
||||
);
|
||||
let hash_map_modification = SystemTime::now();
|
||||
|
||||
//// PROGRESS THREAD START
|
||||
|
@ -511,7 +533,10 @@ impl SimilarImages {
|
|||
|
||||
file_entry.dimensions = format!("{}x{}", dimensions.0, dimensions.1);
|
||||
|
||||
let hasher_config = HasherConfig::new().hash_size(self.hash_size as u32, self.hash_size as u32).hash_alg(self.hash_alg).resize_filter(self.image_filter);
|
||||
let hasher_config = HasherConfig::new()
|
||||
.hash_size(self.hash_size as u32, self.hash_size as u32)
|
||||
.hash_alg(self.hash_alg)
|
||||
.resize_filter(self.image_filter);
|
||||
let hasher = hasher_config.to_hasher();
|
||||
|
||||
let hash = hasher.hash_image(&image);
|
||||
|