Probably works now
This commit is contained in:
parent
c7b1668078
commit
b9689ffd50
|
@ -10,7 +10,7 @@ homepage = "https://github.com/qarmin/czkawka"
|
|||
repository = "https://github.com/qarmin/czkawka"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "3.2.17", features = ["derive"] }
|
||||
clap = { version = "3.2.20", features = ["derive"] }
|
||||
|
||||
# For enum types
|
||||
image_hasher = "1.0.0"
|
||||
|
|
|
@ -26,10 +26,10 @@ hamming = "0.1.3"
|
|||
|
||||
# Needed by same music
|
||||
bitflags = "1.3.2"
|
||||
lofty = "0.8.0"
|
||||
lofty = "0.8.1"
|
||||
|
||||
# Futures - needed by async progress sender
|
||||
futures = "0.3.23"
|
||||
futures = "0.3.24"
|
||||
|
||||
# Needed by broken files
|
||||
zip = { version = "0.6.2", features = ["aes-crypto", "bzip2", "deflate", "time"], default-features = false }
|
||||
|
@ -48,15 +48,15 @@ vid_dup_finder_lib = "0.1.1"
|
|||
ffmpeg_cmdline_utils = "0.1.2"
|
||||
|
||||
# Saving/Loading Cache
|
||||
serde = "1.0.143"
|
||||
serde = "1.0.144"
|
||||
bincode = "1.3.3"
|
||||
serde_json = "1.0.83"
|
||||
serde_json = "1.0.85"
|
||||
|
||||
# Language
|
||||
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
|
||||
i18n-embed-fl = "0.6.4"
|
||||
rust-embed = "6.4.0"
|
||||
once_cell = "1.13.1"
|
||||
once_cell = "1.14.0"
|
||||
|
||||
# Raw image files
|
||||
rawloader = "0.37.1"
|
||||
|
@ -70,7 +70,7 @@ num_cpus = "1.13.1"
|
|||
|
||||
# Heif/Heic
|
||||
libheif-rs = { version = "0.15.0", optional = true }
|
||||
anyhow = { version = "1.0.62", optional = true }
|
||||
anyhow = { version = "1.0.64", optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -753,6 +753,7 @@ impl SimilarImages {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (hash, vec_files) in &normal_files {
|
||||
if vec_files.len() >= 2 {
|
||||
hashes_with_multiple_images.insert(hash);
|
||||
|
@ -819,7 +820,7 @@ impl SimilarImages {
|
|||
let mut found_items = self
|
||||
.bktree
|
||||
.find(hash_to_check, tolerance)
|
||||
.filter(|(similarity, _hash)| *similarity != 0)
|
||||
.filter(|(similarity, _hash)| if self.use_reference_folders { true } else { *similarity != 0 })
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
found_items.sort_unstable_by_key(|f| f.0);
|
||||
|
@ -837,7 +838,9 @@ impl SimilarImages {
|
|||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
debug_check_for_duplicated_things(hashes_parents.clone(), hashes_similarity.clone(), all_hashed_images.clone(), "BEFORE");
|
||||
if !self.use_reference_folders {
|
||||
debug_check_for_duplicated_things(hashes_parents.clone(), hashes_similarity.clone(), all_hashed_images.clone(), "BEFORE");
|
||||
}
|
||||
|
||||
Some((hashes_parents, hashes_similarity))
|
||||
})
|
||||
|
@ -883,7 +886,9 @@ impl SimilarImages {
|
|||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
debug_check_for_duplicated_things(hashes_parents.clone(), hashes_similarity.clone(), all_hashed_images.clone(), "LATTER");
|
||||
if !self.use_reference_folders {
|
||||
debug_check_for_duplicated_things(hashes_parents.clone(), hashes_similarity.clone(), all_hashed_images.clone(), "LATTER");
|
||||
}
|
||||
|
||||
// Just simple check if all original hashes with multiple entries are available in end results
|
||||
let original_hashes_at_start = hashes_with_multiple_images.len();
|
||||
|
@ -892,21 +897,55 @@ impl SimilarImages {
|
|||
.filter(|(parent_hash, _child_number)| hashes_with_multiple_images.contains(*parent_hash))
|
||||
.count();
|
||||
assert_eq!(original_hashes_at_start, original_hashes_in_end_results);
|
||||
// Collecting results to vector
|
||||
for (parent_hash, child_number) in hashes_parents {
|
||||
// If hash contains other hasher OR multiple images are available for checked hash
|
||||
if child_number > 0 || hashes_with_multiple_images.contains(parent_hash) {
|
||||
let vec_fe = all_hashed_images.get(parent_hash).unwrap().clone();
|
||||
collected_similar_images.insert(parent_hash.clone(), vec_fe);
|
||||
}
|
||||
}
|
||||
|
||||
for (child_hash, (parent_hash, similarity)) in hashes_similarity {
|
||||
let mut vec_fe = all_hashed_images.get(child_hash).unwrap().clone();
|
||||
for mut fe in &mut vec_fe {
|
||||
fe.similarity = similarity;
|
||||
if self.use_reference_folders {
|
||||
// This is same step as without reference folders, but also checks if children are inside/outside reference directories, because may happen, that one file is inside reference folder and other outside
|
||||
|
||||
// Collecting results to vector
|
||||
for (parent_hash, child_number) in hashes_parents {
|
||||
// If hash contains other hasher OR multiple images are available for checked hash
|
||||
if child_number > 0 || hashes_with_multiple_images.contains(parent_hash) {
|
||||
let vec_fe = all_hashed_images
|
||||
.get(parent_hash)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|e| is_in_reference_folder(&self.directories.reference_directories, &e.path))
|
||||
.cloned()
|
||||
.collect();
|
||||
collected_similar_images.insert(parent_hash.clone(), vec_fe);
|
||||
}
|
||||
}
|
||||
|
||||
for (child_hash, (parent_hash, similarity)) in hashes_similarity {
|
||||
let mut vec_fe: Vec<_> = all_hashed_images
|
||||
.get(child_hash)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|e| !is_in_reference_folder(&self.directories.reference_directories, &e.path))
|
||||
.cloned()
|
||||
.collect();
|
||||
for mut fe in &mut vec_fe {
|
||||
fe.similarity = similarity;
|
||||
}
|
||||
collected_similar_images.get_mut(parent_hash).unwrap().append(&mut vec_fe);
|
||||
}
|
||||
} else {
|
||||
// Collecting results to vector
|
||||
for (parent_hash, child_number) in hashes_parents {
|
||||
// If hash contains other hasher OR multiple images are available for checked hash
|
||||
if child_number > 0 || hashes_with_multiple_images.contains(parent_hash) {
|
||||
let vec_fe = all_hashed_images.get(parent_hash).unwrap().clone();
|
||||
collected_similar_images.insert(parent_hash.clone(), vec_fe);
|
||||
}
|
||||
}
|
||||
|
||||
for (child_hash, (parent_hash, similarity)) in hashes_similarity {
|
||||
let mut vec_fe = all_hashed_images.get(child_hash).unwrap().clone();
|
||||
for mut fe in &mut vec_fe {
|
||||
fe.similarity = similarity;
|
||||
}
|
||||
collected_similar_images.get_mut(parent_hash).unwrap().append(&mut vec_fe);
|
||||
}
|
||||
collected_similar_images.get_mut(parent_hash).unwrap().append(&mut vec_fe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1082,6 +1121,10 @@ fn image_to_check<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn is_in_reference_folder(reference_directories: &[PathBuf], path: &Path) -> bool {
|
||||
reference_directories.iter().any(|e| path.starts_with(&e))
|
||||
}
|
||||
|
||||
impl Default for SimilarImages {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
|
|
|
@ -20,7 +20,7 @@ chrono = "0.4.22"
|
|||
crossbeam-channel = "0.5.6"
|
||||
|
||||
# To get informations about progress
|
||||
futures = "0.3.23"
|
||||
futures = "0.3.24"
|
||||
|
||||
# For saving/loading config files to specific directories
|
||||
directories-next = "2.0.0"
|
||||
|
@ -47,7 +47,7 @@ fs_extra = "1.2.0"
|
|||
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
|
||||
i18n-embed-fl = "0.6.4"
|
||||
rust-embed = "6.4.0"
|
||||
once_cell = "1.13.1"
|
||||
once_cell = "1.14.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.9", features = ["combaseapi", "objbase", "shobjidl_core", "windef", "winerror", "wtypesbase", "winuser"] }
|
||||
|
|
Loading…
Reference in a new issue