@@ -101,6 +101,7 @@ pub struct SimilarImages {
101
101
image_filter : FilterType ,
102
102
use_cache : bool ,
103
103
delete_outdated_cache : bool ,
104
+ exclude_images_with_same_size : bool ,
104
105
}
105
106
106
107
/// Info struck with helpful information's about results
@@ -140,6 +141,7 @@ impl SimilarImages {
140
141
image_filter : FilterType :: Lanczos3 ,
141
142
use_cache : true ,
142
143
delete_outdated_cache : true ,
144
+ exclude_images_with_same_size : false ,
143
145
}
144
146
}
145
147
@@ -156,6 +158,10 @@ impl SimilarImages {
156
158
self . delete_outdated_cache = delete_outdated_cache;
157
159
}
158
160
161
+ pub fn set_exclude_images_with_same_size ( & mut self , exclude_images_with_same_size : bool ) {
162
+ self . exclude_images_with_same_size = exclude_images_with_same_size;
163
+ }
164
+
159
165
pub fn set_hash_alg ( & mut self , hash_alg : HashAlg ) {
160
166
self . hash_alg = hash_alg;
161
167
}
@@ -384,6 +390,21 @@ impl SimilarImages {
384
390
fn sort_images ( & mut self , stop_receiver : Option < & Receiver < ( ) > > , progress_sender : Option < & futures:: channel:: mpsc:: UnboundedSender < ProgressData > > ) -> bool {
385
391
let hash_map_modification = SystemTime :: now ( ) ;
386
392
393
+ if self . exclude_images_with_same_size {
394
+ let mut old_hash_map = Default :: default ( ) ;
395
+ mem:: swap ( & mut self . images_to_check , & mut old_hash_map) ;
396
+
397
+ let mut new_hash_map: BTreeMap < u64 , FileEntry > = Default :: default ( ) ;
398
+
399
+ for ( _name, file_entry) in old_hash_map {
400
+ new_hash_map. insert ( file_entry. size , file_entry) ;
401
+ }
402
+ self . images_to_check = Default :: default ( ) ;
403
+ for ( _size, file_entry) in new_hash_map {
404
+ self . images_to_check . insert ( file_entry. path . to_string_lossy ( ) . to_string ( ) , file_entry) ;
405
+ }
406
+ }
407
+
387
408
let loaded_hash_map;
388
409
389
410
let mut records_already_cached: BTreeMap < String , FileEntry > = Default :: default ( ) ;
@@ -736,10 +757,6 @@ impl PrintResults for SimilarImages {
736
757
737
758
pub fn save_hashes_to_file ( hashmap : & BTreeMap < String , FileEntry > , text_messages : & mut Messages , hash_size : u8 , hash_alg : HashAlg , image_filter : FilterType ) {
738
759
if let Some ( proj_dirs) = ProjectDirs :: from ( "pl" , "Qarmin" , "Czkawka" ) {
739
- // Lin: /home/username/.cache/czkawka
740
- // Win: C:\Users\Username\AppData\Local\Qarmin\Czkawka\cache
741
- // Mac: /Users/Username/Library/Caches/pl.Qarmin.Czkawka
742
-
743
760
let cache_dir = PathBuf :: from ( proj_dirs. cache_dir ( ) ) ;
744
761
if cache_dir. exists ( ) {
745
762
if !cache_dir. is_dir ( ) {
0 commit comments