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
Changes from 1 commit
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
Next Next commit
Sort unstable
  • Loading branch information
qarmin committed Jul 23, 2022
commit 62bb1d21c147b38699ac49ab711d3478934dc381
40 changes: 20 additions & 20 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
@@ -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"
7 changes: 4 additions & 3 deletions czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
@@ -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"
@@ -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"

@@ -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 }

1 change: 0 additions & 1 deletion czkawka_core/src/bad_extensions.rs
Original file line number Diff line number Diff line change
@@ -148,7 +148,6 @@ static WORKAROUNDS: &[(&str, &str)] = &[
("msi", "doc"), // Not sure whe doc is not recognized
("exe", "xls"), // Not sure whe xls is not recognized
];

#[derive(Clone)]
pub struct BadFileEntry {
pub path: PathBuf,
2 changes: 1 addition & 1 deletion czkawka_core/src/big_file.rs
Original file line number Diff line number Diff line change
@@ -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)
});
10 changes: 5 additions & 5 deletions czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
@@ -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();
@@ -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
2 changes: 1 addition & 1 deletion czkawka_core/src/duplicate.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
2 changes: 1 addition & 1 deletion czkawka_gui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
32 changes: 16 additions & 16 deletions czkawka_gui/src/compute_results.rs
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -216,7 +216,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -276,7 +276,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -339,7 +339,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -395,7 +395,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -449,7 +449,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vector = if vector.len() >= 2 {
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -550,7 +550,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
let hashmap = ef.get_empty_folder_list();
let mut vector = hashmap.keys().cloned().collect::<Vec<PathBuf>>();

vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.as_path());
(t.0, t.1)
});
@@ -616,7 +616,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<

// Sort
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -742,7 +742,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<

// Sort
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -999,7 +999,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone();
vec_file_entry.sort_by_key(|e| {
vec_file_entry.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1057,7 +1057,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone();
vec_file_entry.sort_by_key(|e| {
vec_file_entry.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1181,7 +1181,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone();
vec_file_entry.sort_by_key(|e| {
vec_file_entry.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1252,7 +1252,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let vec_file_entry = if vec_file_entry.len() >= 2 {
let mut vec_file_entry = vec_file_entry.clone();
vec_file_entry.sort_by_key(|e| {
vec_file_entry.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1402,7 +1402,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
// Sort
let mut vector = vector.clone();

vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1474,7 +1474,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<

// Sort
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
@@ -1540,7 +1540,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<

// Sort
let mut vector = vector.clone();
vector.sort_by_key(|e| {
vector.sort_unstable_by_key(|e| {
let t = split_path(e.path.as_path());
(t.0, t.1)
});
2 changes: 1 addition & 1 deletion czkawka_gui/src/connect_things/connect_button_delete.rs
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ pub fn tree_remove(

// Delete duplicated entries, and remove real files
for (path, mut vec_file_name) in map_with_path_to_delete {
vec_file_name.sort();
vec_file_name.sort_unstable();
vec_file_name.dedup();
for file_name in vec_file_name {
if !use_trash {