Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort speedup and manual add window improvements #782

Merged
merged 4 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion czkawka_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://github.com/qarmin/czkawka"
repository = "https://github.com/qarmin/czkawka"

[dependencies]
clap = { version = "3.2.12", features = ["derive"] }
clap = { version = "3.2.14", features = ["derive"] }

# For enum types
image_hasher = "1.0.0"
Expand Down
4 changes: 3 additions & 1 deletion czkawka_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![allow(clippy::needless_late_init)]

use std::process;

use clap::Parser;

use commands::Commands;
#[allow(unused_imports)] // It is used in release for print_results().
use czkawka_core::common_traits::*;
Expand All @@ -18,7 +21,6 @@ use czkawka_core::{
similar_videos::SimilarVideos,
temporary::{self, Temporary},
};
use std::process;

mod commands;

Expand Down
7 changes: 4 additions & 3 deletions czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository = "https://github.com/qarmin/czkawka"
[dependencies]
humansize = "1.1.1"
rayon = "1.5.3"
crossbeam-channel = "0.5.5"
crossbeam-channel = "0.5.6"

# For saving/loading config files to specific directories
directories-next = "2.0.0"
Expand All @@ -26,7 +26,7 @@ hamming = "0.1.3"

# Needed by same music
bitflags = "1.3.2"
lofty= "0.7.2"
lofty = "0.7.3"

# Futures - needed by async progress sender
futures = "0.3.21"
Expand All @@ -48,7 +48,7 @@ vid_dup_finder_lib = "0.1.0"
ffmpeg_cmdline_utils = "0.1.1"

# Saving/Loading Cache
serde = "1.0.139"
serde = "1.0.140"
bincode = "1.3.3"
serde_json = "1.0.82"

Expand All @@ -68,6 +68,7 @@ infer = "0.9.0"

num_cpus = "1.13.1"

# Heif/Heic
libheif-rs = { version = "0.15.0", optional = true }
anyhow = { version = "1.0.58", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/src/big_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl BigFile {
for (size, mut vector) in iter {
if self.information.number_of_real_files < self.number_of_files_to_check {
if vector.len() > 1 {
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
Expand Down
1 change: 1 addition & 0 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ fn check_extension_availability(file_name_lowercase: &str) -> TypeOfFile {
TypeOfFile::Unknown
}
}

fn check_extension_allowed(type_of_file: &TypeOfFile, checked_types: &CheckedTypes) -> bool {
((*type_of_file == TypeOfFile::Image) && ((*checked_types & CheckedTypes::IMAGE) == CheckedTypes::IMAGE))
|| ((*type_of_file == TypeOfFile::PDF) && ((*checked_types & CheckedTypes::PDF) == CheckedTypes::PDF))
Expand Down
5 changes: 2 additions & 3 deletions czkawka_core/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::time::SystemTime;

#[cfg(feature = "heif")]
use anyhow::Result;
use directories_next::ProjectDirs;
use image::{DynamicImage, ImageBuffer, Rgb};
use imagepipe::{ImageSource, Pipeline};

#[cfg(feature = "heif")]
use anyhow::Result;
#[cfg(feature = "heif")]
use libheif_rs::{Channel, ColorSpace, HeifContext, RgbChroma};

Expand Down
6 changes: 3 additions & 3 deletions czkawka_core/src/common_dir_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum CheckingMethod {
Hash,
}

#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct FileEntry {
pub path: PathBuf,
pub size: u64,
Expand All @@ -47,13 +47,13 @@ pub struct FileEntry {

const MAX_NUMBER_OF_SYMLINK_JUMPS: i32 = 20;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SymlinkInfo {
pub destination_path: PathBuf,
pub type_of_error: ErrorType,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ErrorType {
InfiniteRecursion,
NonExistentFile,
Expand Down
10 changes: 5 additions & 5 deletions czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ impl Directories {

// Remove duplicated entries like: "/", "/"

self.excluded_directories.sort();
self.included_directories.sort();
self.reference_directories.sort();
self.excluded_directories.sort_unstable();
self.included_directories.sort_unstable();
self.reference_directories.sort_unstable();

self.excluded_directories.dedup();
self.included_directories.dedup();
Expand Down Expand Up @@ -292,8 +292,8 @@ impl Directories {
}

// Not needed, but better is to have sorted everything
self.excluded_directories.sort();
self.included_directories.sort();
self.excluded_directories.sort_unstable();
self.included_directories.sort_unstable();
Common::print_time(start_time, SystemTime::now(), "optimize_directories".to_string());

// Get device IDs for included directories
Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/src/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ mod tests {
assert_eq!(metadata.modified()?, fs::metadata(&src)?.modified()?);

let mut actual = read_dir(&dir)?.map(|e| e.unwrap().path()).collect::<Vec<PathBuf>>();
actual.sort();
actual.sort_unstable();
assert_eq!(vec![src, dst], actual);
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions czkawka_core/src/same_music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl SameMusic {
}
let mut hash_map: BTreeMap<String, Vec<MusicEntry>> = Default::default();
for file_entry in vec_file_entry {
let mut thing = file_entry.track_title.to_lowercase().trim().to_string();
let mut thing = file_entry.track_title.trim().to_lowercase();
if self.approximate_comparison {
get_approximate_conversion(&mut thing);
}
Expand Down Expand Up @@ -577,7 +577,7 @@ impl SameMusic {
}
let mut hash_map: BTreeMap<String, Vec<MusicEntry>> = Default::default();
for file_entry in vec_file_entry {
let mut thing = file_entry.track_artist.to_lowercase().trim().to_string();
let mut thing = file_entry.track_artist.trim().to_lowercase();
if self.approximate_comparison {
get_approximate_conversion(&mut thing);
}
Expand Down Expand Up @@ -605,7 +605,7 @@ impl SameMusic {
}
let mut hash_map: BTreeMap<String, Vec<MusicEntry>> = Default::default();
for file_entry in vec_file_entry {
let thing = file_entry.year.to_lowercase().trim().to_string();
let thing = file_entry.year.trim().to_lowercase();
if !thing.is_empty() {
hash_map.entry(thing.clone()).or_insert_with(Vec::new).push(file_entry);
}
Expand All @@ -630,7 +630,7 @@ impl SameMusic {
}
let mut hash_map: BTreeMap<String, Vec<MusicEntry>> = Default::default();
for file_entry in vec_file_entry {
let thing = file_entry.length.to_lowercase().trim().to_string();
let thing = file_entry.length.trim().to_lowercase();
if !thing.is_empty() {
hash_map.entry(thing.clone()).or_insert_with(Vec::new).push(file_entry);
}
Expand All @@ -655,7 +655,7 @@ impl SameMusic {
}
let mut hash_map: BTreeMap<String, Vec<MusicEntry>> = Default::default();
for file_entry in vec_file_entry {
let thing = file_entry.genre.to_lowercase().trim().to_string();
let thing = file_entry.genre.trim().to_lowercase();
if !thing.is_empty() {
hash_map.entry(thing.clone()).or_insert_with(Vec::new).push(file_entry);
}
Expand Down
3 changes: 1 addition & 2 deletions czkawka_core/src/similar_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "heif")]
use crate::common::get_dynamic_image_from_heic;
use crate::common::{get_dynamic_image_from_raw_image, open_cache_folder, Common, HEIC_EXTENSIONS, IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS, LOOP_DURATION, RAW_IMAGE_EXTENSIONS};

use crate::common_directory::Directories;
use crate::common_extensions::Extensions;
use crate::common_items::ExcludedItems;
Expand Down Expand Up @@ -570,7 +569,7 @@ impl SimilarImages {
break 'krztyna;
}

# [cfg(feature = "heif")]
#[cfg(feature = "heif")]
if HEIC_EXTENSIONS.iter().any(|e| file_name_lowercase.ends_with(e)) {
image = match get_dynamic_image_from_heic(&file_entry.path.to_string_lossy().to_string()) {
Ok(t) => t,
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ humansize = "1.1.1"
chrono = "0.4.19"

# Used for sending stop signal across threads
crossbeam-channel = "0.5.5"
crossbeam-channel = "0.5.6"

# To get informations about progress
futures = "0.3.21"
Expand Down
14 changes: 12 additions & 2 deletions czkawka_gui/i18n/en/czkawka_gui.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,20 @@ upper_manual_add_excluded_button = Manual Add
upper_add_excluded_button = Add
upper_remove_excluded_button = Remove

upper_manual_add_included_button_tooltip = Add directory name to search by hand.
upper_manual_add_included_button_tooltip =
Add directory name to search by hand.

To add multiple paths at once, separate them by ;

/home/roman;/home/rozkaz will add two directories /home/roman and /home/rozkaz
upper_add_included_button_tooltip = Add new directory to search.
upper_remove_included_button_tooltip = Delete directory from search.
upper_manual_add_excluded_button_tooltip = Add excluded directory name by hand.
upper_manual_add_excluded_button_tooltip =
Add excluded directory name by hand.

To add multiple paths at once, separate them by ;

/home/roman;/home/krokiet will add two directories /home/roman and /home/keokiet
upper_add_excluded_button_tooltip = Add directory to be excluded in search.
upper_remove_excluded_button_tooltip = Delete directory from excluded.

Expand Down
Loading