Skip to content

Commit

Permalink
Proof
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Dec 29, 2024
1 parent f802a58 commit 92c292d
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/minimial_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: sudo apt update || true; sudo apt install libgtk-4-dev libheif-dev libraw-dev ffmpeg -y

- name: Setup rust version
run: rustup default 1.80.0
run: rustup default 1.81.0

- name: Build
run: |
Expand Down
13 changes: 0 additions & 13 deletions Diff

This file was deleted.

2 changes: 1 addition & 1 deletion czkawka_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "czkawka_cli"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
edition = "2021"
rust-version = "1.80.0"
rust-version = "1.81.0"
description = "CLI frontend of Czkawka"
license = "MIT"
homepage = "https://github.com/qarmin/czkawka"
Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "czkawka_core"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
edition = "2021"
rust-version = "1.80.0"
rust-version = "1.81.0"
description = "Core of Czkawka app"
license = "MIT"
homepage = "https://github.com/qarmin/czkawka"
Expand Down
32 changes: 16 additions & 16 deletions czkawka_core/src/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ impl DuplicateFinder {
}
self.calculate_size_name_stats();

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

DirTraversalResult::Stopped => crate::common::WorkContinueStatus::Stop,
DirTraversalResult::Stopped => WorkContinueStatus::Stop,
}
}

Expand Down Expand Up @@ -427,10 +427,10 @@ impl DuplicateFinder {
self.files_with_identical_size_referenced.values().map(|(_fe, vec)| vec.len()).sum::<usize>()
);

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

DirTraversalResult::Stopped => crate::common::WorkContinueStatus::Stop,
DirTraversalResult::Stopped => WorkContinueStatus::Stop,
}
}

Expand Down Expand Up @@ -552,7 +552,7 @@ impl DuplicateFinder {
pre_checked_map: &mut BTreeMap<u64, Vec<DuplicateEntry>>,
) -> WorkContinueStatus {
if self.files_with_identical_size.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

let check_type = self.get_params().hash_type;
Expand All @@ -563,7 +563,7 @@ impl DuplicateFinder {

send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}
let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) = prepare_thread_handler_common(
progress_sender,
Expand Down Expand Up @@ -630,10 +630,10 @@ impl DuplicateFinder {

send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_was_stopped.load(Ordering::Relaxed) || check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

fn diff_loaded_and_prechecked_files(
Expand Down Expand Up @@ -766,7 +766,7 @@ impl DuplicateFinder {
pre_checked_map: BTreeMap<u64, Vec<DuplicateEntry>>,
) -> WorkContinueStatus {
if pre_checked_map.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

let (progress_thread_handle, progress_thread_run, _atomic_counter, _check_was_stopped) =
Expand All @@ -776,7 +776,7 @@ impl DuplicateFinder {

send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) = prepare_thread_handler_common(
Expand Down Expand Up @@ -841,7 +841,7 @@ impl DuplicateFinder {
}
}

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

#[fun_time(message = "hash_reference_folders", level = "debug")]
Expand Down Expand Up @@ -900,20 +900,20 @@ impl DuplicateFinder {
assert_eq!(self.get_params().check_method, CheckingMethod::Hash);

let mut pre_checked_map: BTreeMap<u64, Vec<DuplicateEntry>> = Default::default();
if self.prehashing(stop_receiver, progress_sender, &mut pre_checked_map) == crate::common::WorkContinueStatus::Stop {
return crate::common::WorkContinueStatus::Stop;
if self.prehashing(stop_receiver, progress_sender, &mut pre_checked_map) == WorkContinueStatus::Stop {
return WorkContinueStatus::Stop;
}

if self.full_hashing(stop_receiver, progress_sender, pre_checked_map) == crate::common::WorkContinueStatus::Stop {
return crate::common::WorkContinueStatus::Stop;
if self.full_hashing(stop_receiver, progress_sender, pre_checked_map) == WorkContinueStatus::Stop {
return WorkContinueStatus::Stop;
}

self.hash_reference_folders();

// Clean unused data
self.files_with_identical_size = Default::default();

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

#[fun_time(message = "delete_files", level = "debug")]
Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/src/empty_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl EmptyFolder {
while !folders_to_check.is_empty() {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

let segments: Vec<_> = folders_to_check
Expand Down
4 changes: 2 additions & 2 deletions czkawka_core/src/invalid_symlinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ impl InvalidSymlinks {
self.information.number_of_invalid_symlinks = self.invalid_symlinks.len();
self.common_data.text_messages.warnings.extend(warnings);
debug!("Found {} invalid symlinks.", self.information.number_of_invalid_symlinks);
crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}
DirTraversalResult::Stopped => crate::common::WorkContinueStatus::Stop,
DirTraversalResult::Stopped => WorkContinueStatus::Stop,
}
}

Expand Down
56 changes: 28 additions & 28 deletions czkawka_core/src/same_music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,31 @@ impl SameMusic {
pub fn find_same_music(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) {
self.prepare_items();
self.common_data.use_reference_folders = !self.common_data.directories.reference_directories.is_empty();
if self.check_files(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.check_files(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
match self.params.check_type {
CheckingMethod::AudioTags => {
if self.read_tags(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.read_tags(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
if self.check_for_duplicate_tags(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.check_for_duplicate_tags(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
}
CheckingMethod::AudioContent => {
if self.read_tags(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.read_tags(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
if self.calculate_fingerprint(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.calculate_fingerprint(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
if self.check_for_duplicate_fingerprints(stop_receiver, progress_sender) == crate::common::WorkContinueStatus::Stop {
if self.check_for_duplicate_fingerprints(stop_receiver, progress_sender) == WorkContinueStatus::Stop {
self.common_data.stopped_search = true;
return;
}
Expand All @@ -204,7 +204,7 @@ impl SameMusic {
fn check_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) -> WorkContinueStatus {
self.common_data.extensions.set_and_validate_allowed_extensions(AUDIO_FILES_EXTENSIONS);
if !self.common_data.extensions.set_any_extensions() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

let result = DirTraversalBuilder::new()
Expand All @@ -225,10 +225,10 @@ impl SameMusic {
.collect();
self.common_data.text_messages.warnings.extend(warnings);
debug!("check_files - Found {} music files.", self.music_to_check.len());
crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

DirTraversalResult::Stopped => crate::common::WorkContinueStatus::Stop,
DirTraversalResult::Stopped => WorkContinueStatus::Stop,
}
}

Expand Down Expand Up @@ -285,7 +285,7 @@ impl SameMusic {
#[fun_time(message = "calculate_fingerprint", level = "debug")]
fn calculate_fingerprint(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) -> WorkContinueStatus {
if self.music_entries.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

// We only calculate fingerprints, for files with similar titles
Expand All @@ -310,7 +310,7 @@ impl SameMusic {

send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) = prepare_thread_handler_common(
Expand Down Expand Up @@ -357,15 +357,15 @@ impl SameMusic {
// Break if stop was clicked after saving to cache
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_was_stopped.load(Ordering::Relaxed) || check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}
crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

#[fun_time(message = "read_tags", level = "debug")]
fn read_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) -> WorkContinueStatus {
if self.music_to_check.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

let (progress_thread_handle, progress_thread_run, _atomic_counter, _check_was_stopped) =
Expand All @@ -375,7 +375,7 @@ impl SameMusic {

send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_if_stop_received(stop_receiver) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) =
Expand Down Expand Up @@ -416,16 +416,16 @@ impl SameMusic {
// Break if stop was clicked after saving to cache
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
if check_was_stopped.load(Ordering::Relaxed) {
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

#[fun_time(message = "check_for_duplicate_tags", level = "debug")]
fn check_for_duplicate_tags(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) -> WorkContinueStatus {
if self.music_entries.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}
let (progress_thread_handle, progress_thread_run, atomic_counter, _check_was_stopped) =
prepare_thread_handler_common(progress_sender, CurrentStage::SameMusicComparingTags, self.music_entries.len(), self.get_test_type());
Expand All @@ -436,47 +436,47 @@ impl SameMusic {
if (self.params.music_similarity & MusicSimilarity::TRACK_TITLE) == MusicSimilarity::TRACK_TITLE {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

old_duplicates = self.check_music_item(old_duplicates, &atomic_counter, |fe| &fe.track_title, self.params.approximate_comparison);
}
if (self.params.music_similarity & MusicSimilarity::TRACK_ARTIST) == MusicSimilarity::TRACK_ARTIST {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

old_duplicates = self.check_music_item(old_duplicates, &atomic_counter, |fe| &fe.track_artist, self.params.approximate_comparison);
}
if (self.params.music_similarity & MusicSimilarity::YEAR) == MusicSimilarity::YEAR {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

old_duplicates = self.check_music_item(old_duplicates, &atomic_counter, |fe| &fe.year, false);
}
if (self.params.music_similarity & MusicSimilarity::LENGTH) == MusicSimilarity::LENGTH {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

old_duplicates = self.check_music_item(old_duplicates, &atomic_counter, |fe| &fe.length, false);
}
if (self.params.music_similarity & MusicSimilarity::GENRE) == MusicSimilarity::GENRE {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}

old_duplicates = self.check_music_item(old_duplicates, &atomic_counter, |fe| &fe.genre, false);
}
if (self.params.music_similarity & MusicSimilarity::BITRATE) == MusicSimilarity::BITRATE {
if check_if_stop_received(stop_receiver) {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
}
let old_duplicates_len = old_duplicates.len();
for vec_file_entry in old_duplicates {
Expand Down Expand Up @@ -522,7 +522,7 @@ impl SameMusic {
// Clear unused data
self.music_entries.clear();

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

fn split_fingerprints_to_base_and_files_to_compare(&self, music_data: Vec<MusicEntry>) -> (Vec<MusicEntry>, Vec<MusicEntry>) {
Expand Down Expand Up @@ -647,7 +647,7 @@ impl SameMusic {
#[fun_time(message = "check_for_duplicate_fingerprints", level = "debug")]
fn check_for_duplicate_fingerprints(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&Sender<ProgressData>>) -> WorkContinueStatus {
if self.music_entries.is_empty() {
return crate::common::WorkContinueStatus::Continue;
return WorkContinueStatus::Continue;
}

let grouped_files_to_check = self.split_fingerprints_to_check();
Expand All @@ -661,7 +661,7 @@ impl SameMusic {
let GroupedFilesToCheck { base_files, files_to_compare } = group;
let Some(temp_music_entries) = self.compare_fingerprints(stop_receiver, &atomic_counter, base_files, &files_to_compare) else {
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
return crate::common::WorkContinueStatus::Stop;
return WorkContinueStatus::Stop;
};
duplicated_music_entries.extend(temp_music_entries);
}
Expand Down Expand Up @@ -689,7 +689,7 @@ impl SameMusic {
// Clear unused data
self.music_entries.clear();

crate::common::WorkContinueStatus::Continue
WorkContinueStatus::Continue
}

#[fun_time(message = "check_music_item", level = "debug")]
Expand Down
Loading

0 comments on commit 92c292d

Please sign in to comment.