// This error is a problem with image library, remove check when https://github.com/image-rs/jpeg-decoder/issues/130 will be fixed
if!error_string.contains("spectral selection is not allowed in non-progressive scan"){
letmutfile_entry=file_entry.clone();
file_entry.error_string=error_string;
Some(Some(file_entry))
}else{
Some(None)
letfile_entry_clone=file_entry.clone();
letresult=panic::catch_unwind(||{
matchimage::open(&file_entry.path){
Ok(_)=>Some(None),
Err(t)=>{
leterror_string=t.to_string();
// This error is a problem with image library, remove check when https://github.com/image-rs/jpeg-decoder/issues/130 will be fixed
if!error_string.contains("spectral selection is not allowed in non-progressive scan"){
file_entry.error_string=error_string;
Some(Some(file_entry))
}else{
Some(None)
}
}
}// Something is wrong with image
}
});
// If image crashed during opening, we just skip checking its hash and go on
ifletOk(image_result)=result{
image_result
}else{
println!("Image-rs library crashed when opening \"{:?}\" image, please check if problem happens with latest image-rs version(this can be checked via https://github.com/qarmin/ImageOpening tool) and if it is not reported, please report bug here - https://github.com/image-rs/image/issues",file_entry_clone.path);
letmutfolders_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
// Err(_inspected) => return Some(None), // Something is wrong with image,
// For broken images empty hash is used, because without it will try to resecan files each time when it is called(missing cache file is responsible for it)
// This may cause problems(very rarely), when e.g. file was not available due lack of permissions, but it is available now
Err(_inspected)=>{
letmutbuf=Vec::new();
for_iin0..(self.hash_size*self.hash_size/8){
buf.push(0);
}
file_entry.hash=buf.clone();
returnSome(Some((file_entry,buf)));
letimage;
letresult=panic::catch_unwind(||{
matchimage::open(file_entry.path.clone()){
Ok(t)=>Ok(t),
// Err(_inspected) => return Some(None), // Something is wrong with image,
// For broken images empty hash is used, because without it will try to resecan files each time when it is called(missing cache file is responsible for it)
// This may cause problems(very rarely), when e.g. file was not available due lack of permissions, but it is available now
Err(_inspected)=>Err(()),
}
};
});
// If image crashed during opening, we just skip checking its hash and go on
ifletOk(image_result)=result{
ifletOk(image2)=image_result{
image=image2;
}else{
returnSome(Some((file_entry,Vec::new())));
}
}else{
println!("Image-rs library crashed when opening \"{:?}\" image, please check if problem happens with latest image-rs version(this can be checked via https://github.com/qarmin/ImageOpening tool) and if it is not reported, please report bug here - https://github.com/image-rs/image/issues",file_entry.path);
// All valid entries are used to create bktree used to check for hash similarity
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)