1
0
Fork 0
mirror of synced 2024-06-18 18:34:54 +12:00
This commit is contained in:
Rafał Mikrut 2023-09-15 19:04:05 +02:00
parent a77cb27f3b
commit 1d518ef18f
19 changed files with 389 additions and 363 deletions

627
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,8 @@ members = [
"czkawka_cli", "czkawka_cli",
"czkawka_gui", "czkawka_gui",
] ]
resolver = "2"
[profile.release] [profile.release]
# panic = "unwind" in opposite to "abort", allows to catch panic!() # panic = "unwind" in opposite to "abort", allows to catch panic!()
# Since Czkawka parse different types of files with few libraries, it is possible # Since Czkawka parse different types of files with few libraries, it is possible

View file

@ -25,8 +25,8 @@ image = "0.24"
hamming = "0.1" hamming = "0.1"
# Needed by same music # Needed by same music
bitflags = "2.3" bitflags = "2.4"
lofty = "0.14" lofty = "0.15"
# Futures - needed by async progress sender # Futures - needed by async progress sender
futures = "0.3.28" futures = "0.3.28"
@ -45,7 +45,7 @@ blake3 = "1.4"
crc32fast = "1.3" crc32fast = "1.3"
xxhash-rust = { version = "0.8", features = ["xxh3"] } xxhash-rust = { version = "0.8", features = ["xxh3"] }
tempfile = "3.6" tempfile = "3.8"
# Video Duplicates # Video Duplicates
vid_dup_finder_lib = "0.1" vid_dup_finder_lib = "0.1"
@ -57,9 +57,9 @@ bincode = "1.3"
serde_json = "1.0" serde_json = "1.0"
# Language # Language
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } i18n-embed = { version = "<=0.13", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6" i18n-embed-fl = "0.7"
rust-embed = "6.8" rust-embed = "<=6" # TODO problems when updating to >= 8 version
once_cell = "1.18" once_cell = "1.18"
# Raw image files # Raw image files

View file

@ -327,7 +327,7 @@ impl BadExtensions {
// if hashmap_workarounds.contains_key(found) { // if hashmap_workarounds.contains_key(found) {
// panic!("Already have {} key", found); // panic!("Already have {} key", found);
// } // }
hashmap_workarounds.entry(found).or_insert_with(Vec::new).push(proper); hashmap_workarounds.entry(found).or_default().push(proper);
} }
self.bad_extensions_files = self.verify_extensions(files_to_check, &atomic_counter, stop_receiver, &check_was_stopped, &hashmap_workarounds); self.bad_extensions_files = self.verify_extensions(files_to_check, &atomic_counter, stop_receiver, &check_was_stopped, &hashmap_workarounds);

View file

@ -201,7 +201,7 @@ impl BigFile {
folders_to_check.extend(segment); folders_to_check.extend(segment);
self.text_messages.warnings.extend(warnings); self.text_messages.warnings.extend(warnings);
for (size, fe) in fe_result { for (size, fe) in fe_result {
old_map.entry(size).or_insert_with(Vec::new).push(fe); old_map.entry(size).or_default().push(fe);
} }
} }
} }

View file

@ -489,7 +489,7 @@ where
all_warnings.extend(warnings); all_warnings.extend(warnings);
for fe in fe_result { for fe in fe_result {
let key = (self.group_by)(&fe); let key = (self.group_by)(&fe);
grouped_file_entries.entry(key).or_insert_with(Vec::new).push(fe); grouped_file_entries.entry(key).or_default().push(fe);
} }
for current_folder in &set_as_not_empty_folder_list { for current_folder in &set_as_not_empty_folder_list {
set_as_not_empty_folder(&mut folder_entries, current_folder); set_as_not_empty_folder(&mut folder_entries, current_folder);

View file

@ -624,13 +624,13 @@ impl DuplicateFinder {
let name = file_entry.path.to_string_lossy().to_string(); let name = file_entry.path.to_string_lossy().to_string();
if !loaded_hash_map2.contains_key(&name) { if !loaded_hash_map2.contains_key(&name) {
// If loaded data doesn't contains current image info // If loaded data doesn't contains current image info
non_cached_files_to_check.entry(file_entry.size).or_insert_with(Vec::new).push(file_entry.clone()); non_cached_files_to_check.entry(file_entry.size).or_default().push(file_entry.clone());
} else if file_entry.size != loaded_hash_map2.get(&name).unwrap().size || file_entry.modified_date != loaded_hash_map2.get(&name).unwrap().modified_date { } else if file_entry.size != loaded_hash_map2.get(&name).unwrap().size || file_entry.modified_date != loaded_hash_map2.get(&name).unwrap().modified_date {
// When size or modification date of image changed, then it is clear that is different image // When size or modification date of image changed, then it is clear that is different image
non_cached_files_to_check.entry(file_entry.size).or_insert_with(Vec::new).push(file_entry.clone()); non_cached_files_to_check.entry(file_entry.size).or_default().push(file_entry.clone());
} else { } else {
// Checking may be omitted when already there is entry with same size and modification date // Checking may be omitted when already there is entry with same size and modification date
records_already_cached.entry(file_entry.size).or_insert_with(Vec::new).push(file_entry.clone()); records_already_cached.entry(file_entry.size).or_default().push(file_entry.clone());
} }
} }
} }
@ -702,7 +702,7 @@ impl DuplicateFinder {
for file_entry in vec_file_entry { for file_entry in vec_file_entry {
match hash_calculation(&mut buffer, file_entry, &check_type, 0) { match hash_calculation(&mut buffer, file_entry, &check_type, 0) {
Ok(hash_string) => { Ok(hash_string) => {
hashmap_with_hash.entry(hash_string.clone()).or_insert_with(Vec::new).push(file_entry.clone()); hashmap_with_hash.entry(hash_string.clone()).or_default().push(file_entry.clone());
} }
Err(s) => errors.push(s), Err(s) => errors.push(s),
} }
@ -721,7 +721,7 @@ impl DuplicateFinder {
// Add data from cache // Add data from cache
for (size, vec_file_entry) in &records_already_cached { for (size, vec_file_entry) in &records_already_cached {
pre_checked_map.entry(*size).or_insert_with(Vec::new).append(&mut vec_file_entry.clone()); pre_checked_map.entry(*size).or_default().append(&mut vec_file_entry.clone());
} }
// Check results // Check results
@ -729,7 +729,7 @@ impl DuplicateFinder {
self.text_messages.warnings.append(&mut errors.clone()); self.text_messages.warnings.append(&mut errors.clone());
for vec_file_entry in hash_map.values() { for vec_file_entry in hash_map.values() {
if vec_file_entry.len() > 1 { if vec_file_entry.len() > 1 {
pre_checked_map.entry(*size).or_insert_with(Vec::new).append(&mut vec_file_entry.clone()); pre_checked_map.entry(*size).or_default().append(&mut vec_file_entry.clone());
} }
} }
} }
@ -765,14 +765,14 @@ impl DuplicateFinder {
let mut found: bool = false; let mut found: bool = false;
for loaded_file_entry in loaded_vec_file_entry { for loaded_file_entry in loaded_vec_file_entry {
if file_entry.path == loaded_file_entry.path && file_entry.modified_date == loaded_file_entry.modified_date { if file_entry.path == loaded_file_entry.path && file_entry.modified_date == loaded_file_entry.modified_date {
records_already_cached.entry(file_entry.size).or_insert_with(Vec::new).push(loaded_file_entry.clone()); records_already_cached.entry(file_entry.size).or_default().push(loaded_file_entry.clone());
found = true; found = true;
break; break;
} }
} }
if !found { if !found {
non_cached_files_to_check.entry(file_entry.size).or_insert_with(Vec::new).push(file_entry); non_cached_files_to_check.entry(file_entry.size).or_default().push(file_entry);
} }
} }
} }
@ -798,7 +798,7 @@ impl DuplicateFinder {
for (full_size, full_hashmap, _errors) in &mut (*full_hash_results) { for (full_size, full_hashmap, _errors) in &mut (*full_hash_results) {
if size == *full_size { if size == *full_size {
for file_entry in vec_file_entry { for file_entry in vec_file_entry {
full_hashmap.entry(file_entry.hash.clone()).or_insert_with(Vec::new).push(file_entry); full_hashmap.entry(file_entry.hash.clone()).or_default().push(file_entry);
} }
continue 'main; continue 'main;
} }
@ -806,7 +806,7 @@ impl DuplicateFinder {
// Size doesn't exists add results to files // Size doesn't exists add results to files
let mut temp_hashmap: BTreeMap<String, Vec<FileEntry>> = Default::default(); let mut temp_hashmap: BTreeMap<String, Vec<FileEntry>> = Default::default();
for file_entry in vec_file_entry { for file_entry in vec_file_entry {
temp_hashmap.entry(file_entry.hash.clone()).or_insert_with(Vec::new).push(file_entry); temp_hashmap.entry(file_entry.hash.clone()).or_default().push(file_entry);
} }
full_hash_results.push((size, temp_hashmap, Vec::new())); full_hash_results.push((size, temp_hashmap, Vec::new()));
} }
@ -860,7 +860,7 @@ impl DuplicateFinder {
match hash_calculation(&mut buffer, &file_entry, &check_type, u64::MAX) { match hash_calculation(&mut buffer, &file_entry, &check_type, u64::MAX) {
Ok(hash_string) => { Ok(hash_string) => {
file_entry.hash = hash_string.clone(); file_entry.hash = hash_string.clone();
hashmap_with_hash.entry(hash_string.clone()).or_insert_with(Vec::new).push(file_entry); hashmap_with_hash.entry(hash_string.clone()).or_default().push(file_entry);
} }
Err(s) => errors.push(s), Err(s) => errors.push(s),
} }
@ -883,7 +883,7 @@ impl DuplicateFinder {
self.text_messages.warnings.append(&mut errors); self.text_messages.warnings.append(&mut errors);
for (_hash, vec_file_entry) in hash_map { for (_hash, vec_file_entry) in hash_map {
if vec_file_entry.len() > 1 { if vec_file_entry.len() > 1 {
self.files_with_identical_hashes.entry(size).or_insert_with(Vec::new).push(vec_file_entry); self.files_with_identical_hashes.entry(size).or_default().push(vec_file_entry);
} }
} }
} }
@ -982,7 +982,7 @@ impl DuplicateFinder {
} }
CheckingMethod::Hash => { CheckingMethod::Hash => {
for vector_vectors in self.files_with_identical_hashes.values() { for vector_vectors in self.files_with_identical_hashes.values() {
for vector in vector_vectors.iter() { for vector in vector_vectors {
let _tuple: (u64, usize, usize) = delete_files(vector, &self.delete_method, &mut self.text_messages, self.dryrun); let _tuple: (u64, usize, usize) = delete_files(vector, &self.delete_method, &mut self.text_messages, self.dryrun);
} }
} }
@ -1305,7 +1305,7 @@ fn delete_files(vector: &[FileEntry], delete_method: &DeleteMethod, text_message
if dryrun { if dryrun {
Ok(Some(format!("Delete {}", file.path.display()))) Ok(Some(format!("Delete {}", file.path.display())))
} else { } else {
fs::remove_file(&file.path).map(|_| None) fs::remove_file(&file.path).map(|()| None)
} }
} }
DeleteMethod::HardLink => { DeleteMethod::HardLink => {
@ -1313,7 +1313,7 @@ fn delete_files(vector: &[FileEntry], delete_method: &DeleteMethod, text_message
if dryrun { if dryrun {
Ok(Some(format!("Replace file {} with hard link to {}", file.path.display(), src.display()))) Ok(Some(format!("Replace file {} with hard link to {}", file.path.display(), src.display())))
} else { } else {
make_hard_link(src, &file.path).map(|_| None) make_hard_link(src, &file.path).map(|()| None)
} }
} }
DeleteMethod::None => Ok(None), DeleteMethod::None => Ok(None),
@ -1401,7 +1401,9 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
open_cache_folder(&get_file_hash_name(type_of_hash, is_prehash), false, false, &mut text_messages.warnings) open_cache_folder(&get_file_hash_name(type_of_hash, is_prehash), false, false, &mut text_messages.warnings)
{ {
// Unwrap could fail when failed to open cache file, but json would exists // Unwrap could fail when failed to open cache file, but json would exists
let Some(file_handler) = file_handler else { return Default::default(); }; let Some(file_handler) = file_handler else {
return Default::default();
};
let reader = BufReader::new(file_handler); let reader = BufReader::new(file_handler);
let mut hashmap_loaded_entries: BTreeMap<u64, Vec<FileEntry>> = Default::default(); let mut hashmap_loaded_entries: BTreeMap<u64, Vec<FileEntry>> = Default::default();
@ -1460,7 +1462,7 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
hash: uuu[3].to_string(), hash: uuu[3].to_string(),
symlink_info: None, symlink_info: None,
}; };
hashmap_loaded_entries.entry(file_entry.size).or_insert_with(Vec::new).push(file_entry); hashmap_loaded_entries.entry(file_entry.size).or_default().push(file_entry);
} }
} }

View file

@ -168,7 +168,7 @@ impl EmptyFolder {
// 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) {
Ok(_) => (), Ok(()) => (),
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)),
}; };
} }

View file

@ -430,8 +430,8 @@ impl SameMusic {
return None; return None;
} }
let Ok(fingerprint) = calc_fingerprint_helper(path, configuration) else { let Ok(fingerprint) = calc_fingerprint_helper(path, configuration) else {
return Some(None); return Some(None);
}; };
music_entry.fingerprint = fingerprint; music_entry.fingerprint = fingerprint;
@ -561,7 +561,7 @@ impl SameMusic {
if file_entry.bitrate != 0 { if file_entry.bitrate != 0 {
let thing = file_entry.bitrate.to_string(); let thing = file_entry.bitrate.to_string();
if !thing.is_empty() { if !thing.is_empty() {
hash_map.entry(thing.clone()).or_insert_with(Vec::new).push(file_entry); hash_map.entry(thing.clone()).or_default().push(file_entry);
} }
} }
} }
@ -778,7 +778,7 @@ impl SameMusic {
get_approximate_conversion(&mut thing); get_approximate_conversion(&mut thing);
} }
if !thing.is_empty() { if !thing.is_empty() {
hash_map.entry(thing).or_insert_with(Vec::new).push(file_entry); hash_map.entry(thing).or_default().push(file_entry);
} }
} }
for (_title, vec_file_entry) in hash_map { for (_title, vec_file_entry) in hash_map {
@ -924,7 +924,7 @@ fn calc_fingerprint_helper(path: impl AsRef<Path>, config: &Configuration) -> an
let mut sample_buf = None; let mut sample_buf = None;
loop { loop {
let Ok(packet) = format.next_packet() else { break }; let Ok(packet) = format.next_packet() else { break };
if packet.track_id() != track_id { if packet.track_id() != track_id {
continue; continue;
@ -953,7 +953,9 @@ fn calc_fingerprint_helper(path: impl AsRef<Path>, config: &Configuration) -> an
} }
fn read_single_file_tag(path: &str, music_entry: &mut MusicEntry) -> bool { fn read_single_file_tag(path: &str, music_entry: &mut MusicEntry) -> bool {
let Ok(mut file) = File::open(path) else { return false; }; let Ok(mut file) = File::open(path) else {
return false;
};
let result = panic::catch_unwind(move || { let result = panic::catch_unwind(move || {
match read_from(&mut file) { match read_from(&mut file) {

View file

@ -462,7 +462,7 @@ impl SimilarImages {
for (file_entry, buf) in &vec_file_entry { for (file_entry, buf) in &vec_file_entry {
// Only use to comparing, non broken hashes(all 0 or 255 hashes means that algorithm fails to decode them because e.g. contains a log of alpha channel) // Only use to comparing, non broken hashes(all 0 or 255 hashes means that algorithm fails to decode them because e.g. contains a log of alpha channel)
if !(buf.is_empty() || buf.iter().all(|e| *e == 0) || buf.iter().all(|e| *e == 255)) { if !(buf.is_empty() || buf.iter().all(|e| *e == 0) || buf.iter().all(|e| *e == 255)) {
self.image_hashes.entry(buf.clone()).or_insert_with(Vec::<FileEntry>::new).push(file_entry.clone()); self.image_hashes.entry(buf.clone()).or_default().push(file_entry.clone());
} }
} }
@ -579,9 +579,9 @@ impl SimilarImages {
all_hashed_images.clone().into_iter().for_each(|(hash, vec_file_entry)| { all_hashed_images.clone().into_iter().for_each(|(hash, vec_file_entry)| {
for file_entry in vec_file_entry { for file_entry in vec_file_entry {
if is_in_reference_folder(&self.directories.reference_directories, &file_entry.path) { if is_in_reference_folder(&self.directories.reference_directories, &file_entry.path) {
files_from_referenced_folders.entry(hash.clone()).or_insert_with(Vec::new).push(file_entry); files_from_referenced_folders.entry(hash.clone()).or_default().push(file_entry);
} else { } else {
normal_files.entry(hash.clone()).or_insert_with(Vec::new).push(file_entry); normal_files.entry(hash.clone()).or_default().push(file_entry);
} }
} }
}); });
@ -1685,7 +1685,7 @@ mod tests {
fn add_hashes(hashmap: &mut HashMap<ImHash, Vec<FileEntry>>, file_entries: Vec<FileEntry>) { fn add_hashes(hashmap: &mut HashMap<ImHash, Vec<FileEntry>>, file_entries: Vec<FileEntry>) {
for fe in file_entries { for fe in file_entries {
hashmap.entry(fe.hash.clone()).or_insert_with(Vec::new).push(fe); hashmap.entry(fe.hash.clone()).or_default().push(fe);
} }
} }

View file

@ -324,8 +324,7 @@ impl SimilarVideos {
} }
fn add_video_file_entry(&self, metadata: &Metadata, entry_data: &DirEntry, fe_result: &mut Vec<(String, FileEntry)>, warnings: &mut Vec<String>, current_folder: &Path) { fn add_video_file_entry(&self, metadata: &Metadata, entry_data: &DirEntry, fe_result: &mut Vec<(String, FileEntry)>, warnings: &mut Vec<String>, current_folder: &Path) {
let Some(file_name_lowercase) = get_lowercase_name(entry_data, let Some(file_name_lowercase) = get_lowercase_name(entry_data, warnings) else {
warnings) else {
return; return;
}; };

View file

@ -14,7 +14,7 @@ gdk4 = "0.6"
glib = "0.17" glib = "0.17"
humansize = "2.1" humansize = "2.1"
chrono = "0.4.26" chrono = "0.4.31"
# Used for sending stop signal across threads # Used for sending stop signal across threads
crossbeam-channel = "0.5.8" crossbeam-channel = "0.5.8"
@ -44,9 +44,9 @@ trash = "3.0"
fs_extra = "1.3" fs_extra = "1.3"
# Language # Language
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } i18n-embed = { version = "<=0.13", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6" i18n-embed-fl = "0.7"
rust-embed = "6.8" rust-embed = "<=6" # TODO problems when updating to >= 8 version
once_cell = "1.18" once_cell = "1.18"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]

View file

@ -659,7 +659,7 @@ fn computer_similar_videos(
if ff.get_use_reference() { if ff.get_use_reference() {
let vec_struct_similar = ff.get_similar_videos_referenced(); let vec_struct_similar = ff.get_similar_videos_referenced();
for (base_file_entry, vec_file_entry) in vec_struct_similar.iter() { for (base_file_entry, vec_file_entry) in vec_struct_similar {
// Sort // Sort
let vec_file_entry = if vec_file_entry.len() >= 2 { let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone(); let mut vec_file_entry = vec_file_entry.clone();
@ -681,7 +681,7 @@ fn computer_similar_videos(
} else { } else {
let vec_struct_similar = ff.get_similar_videos(); let vec_struct_similar = ff.get_similar_videos();
for vec_file_entry in vec_struct_similar.iter() { for vec_file_entry in vec_struct_similar {
// Sort // Sort
let vec_file_entry = if vec_file_entry.len() >= 2 { let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone(); let mut vec_file_entry = vec_file_entry.clone();
@ -761,7 +761,7 @@ fn computer_similar_images(
if sf.get_use_reference() { if sf.get_use_reference() {
let vec_struct_similar: &Vec<(similar_images::FileEntry, Vec<similar_images::FileEntry>)> = sf.get_similar_images_referenced(); let vec_struct_similar: &Vec<(similar_images::FileEntry, Vec<similar_images::FileEntry>)> = sf.get_similar_images_referenced();
for (base_file_entry, vec_file_entry) in vec_struct_similar.iter() { for (base_file_entry, vec_file_entry) in vec_struct_similar {
// Sort // Sort
let vec_file_entry = if vec_file_entry.len() >= 2 { let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone(); let mut vec_file_entry = vec_file_entry.clone();
@ -804,7 +804,7 @@ fn computer_similar_images(
} }
} else { } else {
let vec_struct_similar = sf.get_similar_images(); let vec_struct_similar = sf.get_similar_images();
for vec_file_entry in vec_struct_similar.iter() { for vec_file_entry in vec_struct_similar {
// Sort // Sort
let vec_file_entry = if vec_file_entry.len() >= 2 { let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone(); let mut vec_file_entry = vec_file_entry.clone();
@ -956,7 +956,7 @@ fn computer_big_files(
let vector = bf.get_big_files(); let vector = bf.get_big_files();
for (size, file_entry) in vector.iter() { for (size, file_entry) in vector {
let (directory, file) = split_path(&file_entry.path); let (directory, file) = split_path(&file_entry.path);
let values: [(u32, &dyn ToValue); COLUMNS_NUMBER] = [ let values: [(u32, &dyn ToValue); COLUMNS_NUMBER] = [
(ColumnsBigFiles::SelectionButton as u32, &false), (ColumnsBigFiles::SelectionButton as u32, &false),

View file

@ -353,14 +353,14 @@ pub fn empty_folder_remover(
if !error_happened { if !error_happened {
if !use_trash { if !use_trash {
match fs::remove_dir_all(get_full_name_from_path_name(&path, &name)) { match fs::remove_dir_all(get_full_name_from_path_name(&path, &name)) {
Ok(_) => { Ok(()) => {
model.remove(&iter); model.remove(&iter);
} }
Err(_inspected) => error_happened = true, Err(_inspected) => error_happened = true,
} }
} else { } else {
match trash::delete(get_full_name_from_path_name(&path, &name)) { match trash::delete(get_full_name_from_path_name(&path, &name)) {
Ok(_) => { Ok(()) => {
model.remove(&iter); model.remove(&iter);
} }
Err(_inspected) => error_happened = true, Err(_inspected) => error_happened = true,
@ -420,7 +420,7 @@ pub fn basic_remove(
if !use_trash { if !use_trash {
match fs::remove_file(get_full_name_from_path_name(&path, &name)) { match fs::remove_file(get_full_name_from_path_name(&path, &name)) {
Ok(_) => { Ok(()) => {
model.remove(&iter); model.remove(&iter);
} }
@ -435,7 +435,7 @@ pub fn basic_remove(
} }
} else { } else {
match trash::delete(get_full_name_from_path_name(&path, &name)) { match trash::delete(get_full_name_from_path_name(&path, &name)) {
Ok(_) => { Ok(()) => {
model.remove(&iter); model.remove(&iter);
} }
Err(e) => { Err(e) => {
@ -503,7 +503,7 @@ pub fn tree_remove(
model.remove(&iter); model.remove(&iter);
map_with_path_to_delete.entry(path.clone()).or_insert_with(Vec::new).push(file_name); map_with_path_to_delete.entry(path.clone()).or_default().push(file_name);
} }
// Delete duplicated entries, and remove real files // Delete duplicated entries, and remove real files

View file

@ -84,7 +84,7 @@ pub fn connect_button_search(gui_data: &GuiData, glib_stop_sender: Sender<Messag
let glib_stop_sender = glib_stop_sender.clone(); let glib_stop_sender = glib_stop_sender.clone();
let stop_receiver = stop_receiver.clone(); let stop_receiver = stop_receiver.clone();
// Consume any stale stop messages. // Consume any stale stop messages.
stop_receiver.try_iter().for_each(|_| ()); stop_receiver.try_iter().for_each(|()| ());
label_stage.show(); label_stage.show();

View file

@ -8,7 +8,7 @@ use crate::help_functions::KEY_ENTER;
fn send_stop_message(stop_sender: &Sender<()>) { fn send_stop_message(stop_sender: &Sender<()>) {
stop_sender stop_sender
.try_send(()) .try_send(())
.map_or_else(|e| if matches!(e, TrySendError::Full(_)) { Ok(()) } else { Err(e) }, |_| Ok(())) .map_or_else(|e| if matches!(e, TrySendError::Full(())) { Ok(()) } else { Err(e) }, |()| Ok(()))
.unwrap(); .unwrap();
} }

View file

@ -27,7 +27,7 @@ use crate::notebook_info::NOTEBOOKS_INFO;
use crate::opening_selecting_records::*; use crate::opening_selecting_records::*;
use crate::{delete_things, flg}; use crate::{delete_things, flg};
pub fn initialize_gui(gui_data: &mut GuiData) { pub fn initialize_gui(gui_data: &GuiData) {
//// Initialize button //// Initialize button
{ {
let buttons = &gui_data.bottom_buttons.buttons_array; let buttons = &gui_data.bottom_buttons.buttons_array;

View file

@ -77,7 +77,7 @@ fn main() {
} }
fn build_ui(application: &Application, arguments: &[OsString]) { fn build_ui(application: &Application, arguments: &[OsString]) {
let mut gui_data: GuiData = GuiData::new_with_application(application); let gui_data: GuiData = GuiData::new_with_application(application);
// Used for getting data from thread // Used for getting data from thread
let (glib_stop_sender, glib_stop_receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); let (glib_stop_sender, glib_stop_receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
@ -85,7 +85,7 @@ fn build_ui(application: &Application, arguments: &[OsString]) {
// Futures progress report // Futures progress report
let (progress_sender, progress_receiver): (UnboundedSender<ProgressData>, UnboundedReceiver<ProgressData>) = mpsc::unbounded(); let (progress_sender, progress_receiver): (UnboundedSender<ProgressData>, UnboundedReceiver<ProgressData>) = mpsc::unbounded();
initialize_gui(&mut gui_data); initialize_gui(&gui_data);
validate_notebook_data(&gui_data); // Must be run after initialization of gui, to check if everything was properly setup validate_notebook_data(&gui_data); // Must be run after initialization of gui, to check if everything was properly setup
reset_configuration(false, &gui_data.upper_notebook, &gui_data.main_notebook, &gui_data.settings, &gui_data.text_view_errors); // Fallback for invalid loading setting project reset_configuration(false, &gui_data.upper_notebook, &gui_data.main_notebook, &gui_data.settings, &gui_data.text_view_errors); // Fallback for invalid loading setting project
load_system_language(&gui_data); // Check for default system language, must be loaded after initializing GUI and before loading settings from file load_system_language(&gui_data); // Check for default system language, must be loaded after initializing GUI and before loading settings from file

View file

@ -316,7 +316,7 @@ impl LoadSaveStruct {
if line.starts_with("--") { if line.starts_with("--") {
header = line.to_string(); header = line.to_string();
} else if !header.is_empty() { } else if !header.is_empty() {
self.loaded_items.entry(header.clone()).or_insert_with(Vec::new).push(line.to_string()); self.loaded_items.entry(header.clone()).or_default().push(line.to_string());
} else { } else {
add_text_to_text_view( add_text_to_text_view(
text_view_errors, text_view_errors,
@ -1032,7 +1032,7 @@ pub fn reset_configuration(manual_clearing: bool, upper_notebook: &GuiUpperNoteb
let tree_view_excluded_directories = upper_notebook.tree_view_excluded_directories.clone(); let tree_view_excluded_directories = upper_notebook.tree_view_excluded_directories.clone();
let list_store = get_list_store(&tree_view_excluded_directories); let list_store = get_list_store(&tree_view_excluded_directories);
list_store.clear(); list_store.clear();
for i in DEFAULT_EXCLUDED_DIRECTORIES.iter() { for i in DEFAULT_EXCLUDED_DIRECTORIES {
let values: [(u32, &dyn ToValue); 1] = [(ColumnsExcludedDirectory::Path as u32, &i)]; let values: [(u32, &dyn ToValue); 1] = [(ColumnsExcludedDirectory::Path as u32, &i)];
list_store.set(&list_store.append(), &values); list_store.set(&list_store.append(), &values);
} }