Skip to content

Commit

Permalink
Fix CI, print results also in CLI, show errors when image cannot be r…
Browse files Browse the repository at this point in the history
…eaded (#1355)
  • Loading branch information
qarmin authored Sep 27, 2024
1 parent ad832ea commit 12ab601
Show file tree
Hide file tree
Showing 25 changed files with 338 additions and 301 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install Dependencies
run: sudo apt update || true; sudo apt install libgtk-4-dev libheif-dev librsvg2-dev wget fuse libfuse2 -y
run: sudo apt update || true; sudo apt install libgtk-4-dev libheif-dev librsvg2-dev wget fuse libfuse2 desktop-file-utils -y

- name: Setup rust version
run: rustup default ${{ matrix.toolchain }}
Expand All @@ -143,7 +143,7 @@ jobs:
pwd
cp target/release/czkawka_gui AppDir/usr/bin
./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin gtk --icon-file data/icons/com.github.qarmin.czkawka.svg --desktop-file data/com.github.qarmin.czkawka.desktop
./appimagetool --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 20 \
./appimagetool-x86_64.AppImage --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 20 \
-u "gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|czkawka|latest|*.AppImage.zsync" \
./AppDir
Expand Down
49 changes: 25 additions & 24 deletions Cargo.lock

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

28 changes: 18 additions & 10 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@

### Core

- Removed some unnecessary panics
- Simplified usage of structures when sending/receiving progress information
- Added Median hash algorithm
- Fixed compilation with Rust >=1.80
- Extracted tool input parameters, that helped to find not used parameters
- Added new mod to find similar music only in groups with similar title tag
- Removed some unnecessary panics - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Simplified usage of structures when sending/receiving progress
information - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Added Median hash algorithm - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Fixed compilation with Rust >=1.80 - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Extracted tool input parameters, that helped to find not used
parameters - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Added new mod to find similar music only in groups with similar title
tag - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Printing to file/console no longer uses two backslashes in windows
paths - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Fixed panic when failed to decode raw picture - [#1355](https://github.com/qarmin/czkawka/pull/1355)

### Krokiet

- Fixed invalid default hash size in similar images
- Fixed and added more input parameters to the application
- Fixed invalid default hash size in similar images - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Fixed and added more input parameters to the application - [#1354](https://github.com/qarmin/czkawka/pull/1354)

### GTK GUI

- Fixed and added more input parameters to the application
- Fixed and added more input parameters to the application - [#1355](https://github.com/qarmin/czkawka/pull/1355)

### CLI

- Fixed and added more input parameters to the application
- Fixed and added more input parameters to the application - [#1354](https://github.com/qarmin/czkawka/pull/1354)
- Fixed crash when stopping scan mutliple times - [#1355](https://github.com/qarmin/czkawka/pull/1355)
- Print results also in debug build - [#1355](https://github.com/qarmin/czkawka/pull/1355)

## Version 7.0.0 - 19.02.2024r

Expand Down
11 changes: 8 additions & 3 deletions ci_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn main() {

for _ in 0..ATTEMPTS {
test_empty_files();
test_big_files();
test_smallest_files();
test_biggest_files();
test_empty_folders();
Expand Down Expand Up @@ -373,6 +374,11 @@ fn test_empty_files() {
run_test(&["empty-files", "-d", "TestFiles", "-D"], vec!["EmptyFile"], vec![], vec![]);
}

fn test_big_files() {
info!("test_big_files");
run_test(&["big", "-d", "TestFiles", "-n", "2", "-D"], vec!["Music/M4.mp3", "Videos/V3.webm"], vec![], vec![]);
}

////////////////////////////////////
////////////////////////////////////
/////////HELPER FUNCTIONS///////////
Expand Down Expand Up @@ -454,8 +460,7 @@ fn collect_all_files_and_dirs(dir: &str) -> std::io::Result<CollectedFiles> {
let mut symlinks = BTreeSet::new();

let mut folders_to_check = vec![dir.to_string()];
while !folders_to_check.is_empty() {
let folder = folders_to_check.pop().expect("Should not fail in tests");
while let Some(folder) = folders_to_check.pop() {
let rd = fs::read_dir(folder)?;
for entry in rd {
let entry = entry?;
Expand All @@ -470,7 +475,7 @@ fn collect_all_files_and_dirs(dir: &str) -> std::io::Result<CollectedFiles> {
} else if file_type.is_file() {
files.insert(path_str);
} else {
panic!("Unknown type of file {path_str:?}");
panic!("Unknown type of file {path_str}");
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions czkawka_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ fn main() {
})
.expect("Failed to spawn calculation thread");
ctrlc::set_handler(move || {
println!("Get Sender");
stop_sender.send(()).expect("Could not send signal on channel.");
println!("Get Ctrl+C signal, stopping...");
if let Err(e) = stop_sender.send(()) {
eprintln!("Failed to send stop signal {e}(it is possible that the program is already stopped)");
};
})
.expect("Error setting Ctrl-C handler");

Expand Down Expand Up @@ -348,9 +350,8 @@ fn save_and_print_results<T: CommonData + PrintResults>(component: &mut T, commo
}
}

if !cfg!(debug_assertions) {
component.print_results_to_output();
}
component.print_results_to_output();

component.get_text_messages().print_messages();
}

Expand Down
3 changes: 2 additions & 1 deletion czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ os_info = { version = "3", default-features = false }
log = "0.4.22"
handsome_logger = "0.8"
fun_time = { version = "0.3", features = ["log"] }
itertools = "0.13"

[target.'cfg(windows)'.dependencies]
# Don't update anymore! This crate has a bug. I've submitted a patch upstream, but the change is breaking. The current code relies on the bug to work correctly!
# Warning by CalunVier 2024.7.15
[target.'cfg(windows)'.dependencies]
file-id = "=0.2.1"

[build-dependencies]
Expand Down
8 changes: 3 additions & 5 deletions czkawka_core/src/bad_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const WORKAROUNDS: &[(&str, &str)] = &[
("pptx", "ppsx"), // Powerpoint
("sh", "bash"), // Linux
("sh", "guess"), // GNU
("sh", "lua"), // Lua
("sh", "js"), // Javascript
("sh", "pl"), // Gnome/Linux
("sh", "pm"), // Gnome/Linux
("sh", "py"), // Python
Expand Down Expand Up @@ -268,10 +270,6 @@ impl BadExtensions {

let mut hashmap_workarounds: HashMap<&str, Vec<&str>> = Default::default();
for (proper, found) in WORKAROUNDS {
// This should be enabled when items will have only 1 possible workaround items, but looks that some have 2 or even more, so at least for now this is disabled
// if hashmap_workarounds.contains_key(found) {
// panic!("Already have {} key", found);
// }
hashmap_workarounds.entry(found).or_default().push(proper);
}

Expand Down Expand Up @@ -441,7 +439,7 @@ impl PrintResults for BadExtensions {
writeln!(writer, "Found {} files with invalid extension.\n", self.information.number_of_files_with_bad_extension)?;

for file_entry in &self.bad_extensions_files {
writeln!(writer, "{:?} ----- {}", file_entry.path, file_entry.proper_extensions)?;
writeln!(writer, "\"{}\" ----- {}", file_entry.path.to_string_lossy(), file_entry.proper_extensions)?;
}

Ok(())
Expand Down
14 changes: 10 additions & 4 deletions czkawka_core/src/big_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum SearchMode {
SmallestFiles,
}

#[derive(Default)]
#[derive(Debug, Default)]
pub struct Info {
pub number_of_real_files: usize,
}
Expand Down Expand Up @@ -126,8 +126,8 @@ impl DebugPrint for BigFile {
}

println!("### INDIVIDUAL DEBUG PRINT ###");
println!("Big files size {} in {} groups", self.information.number_of_real_files, self.big_files.len());
println!("Number of files to check - {:?}", self.get_params().number_of_files_to_check);
println!("Info: {:?}", self.information);
println!("Number of files to check - {}", self.get_params().number_of_files_to_check);
self.debug_print_common();
println!("-----------------------------------------");
}
Expand All @@ -150,7 +150,13 @@ impl PrintResults for BigFile {
writeln!(writer, "{} the smallest files.\n\n", self.information.number_of_real_files)?;
}
for file_entry in &self.big_files {
writeln!(writer, "{} ({}) - {:?}", format_size(file_entry.size, BINARY), file_entry.size, file_entry.path)?;
writeln!(
writer,
"{} ({}) - \"{}\"",
format_size(file_entry.size, BINARY),
file_entry.size,
file_entry.path.to_string_lossy()
)?;
}
} else {
writeln!(writer, "Not found any files.")?;
Expand Down
14 changes: 4 additions & 10 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::common::{
check_if_stop_received, create_crash_message, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, AUDIO_FILES_EXTENSIONS,
IMAGE_RS_BROKEN_FILES_EXTENSIONS, PDF_FILES_EXTENSIONS, ZIP_FILES_EXTENSIONS,
};
use crate::common_cache::{get_broken_files_cache_file, load_cache_from_file_generalized_by_path, save_cache_to_file_generalized};
use crate::common_cache::{extract_loaded_cache, get_broken_files_cache_file, load_cache_from_file_generalized_by_path, save_cache_to_file_generalized};
use crate::common_dir_traversal::{DirTraversalBuilder, DirTraversalResult, FileEntry, ToolType};
use crate::common_tool::{CommonData, CommonToolData, DeleteMethod};
use crate::common_traits::*;
Expand Down Expand Up @@ -284,13 +284,7 @@ impl BrokenFiles {
self.get_text_messages_mut().extend_with_another_messages(messages);
loaded_hash_map = loaded_items.unwrap_or_default();

for (name, file_entry) in files_to_check {
if let Some(cached_file_entry) = loaded_hash_map.get(&name) {
records_already_cached.insert(name, cached_file_entry.clone());
} else {
non_cached_files_to_check.insert(name, file_entry);
}
}
extract_loaded_cache(&loaded_hash_map, files_to_check, &mut records_already_cached, &mut non_cached_files_to_check);
} else {
loaded_hash_map = Default::default();
non_cached_files_to_check = files_to_check;
Expand Down Expand Up @@ -421,7 +415,7 @@ impl PrintResults for BrokenFiles {
if !self.broken_files.is_empty() {
writeln!(writer, "Found {} broken files.", self.information.number_of_broken_files)?;
for file_entry in &self.broken_files {
writeln!(writer, "{:?} - {}", file_entry.path, file_entry.error_string)?;
writeln!(writer, "\"{}\" - {}", file_entry.path.to_string_lossy(), file_entry.error_string)?;
}
} else {
write!(writer, "Not found any broken files.")?;
Expand Down Expand Up @@ -462,7 +456,7 @@ fn check_extension_availability(
} else if pdf_extensions.contains(&extension_lowercase.as_str()) {
TypeOfFile::PDF
} else {
eprintln!("File with unknown extension: {full_name:?} - {extension_lowercase}");
eprintln!("File with unknown extension: \"{}\" - {extension_lowercase}", full_name.to_string_lossy());
debug_assert!(false, "File with unknown extension");
TypeOfFile::Unknown
}
Expand Down
Loading

0 comments on commit 12ab601

Please sign in to comment.