Skip to content

Commit 12ab601

Browse files
authored
Fix CI, print results also in CLI, show errors when image cannot be readed (#1355)
1 parent ad832ea commit 12ab601

25 files changed

+338
-301
lines changed

.github/workflows/linux_gui.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
- uses: actions/checkout@v4
119119

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

123123
- name: Setup rust version
124124
run: rustup default ${{ matrix.toolchain }}
@@ -143,7 +143,7 @@ jobs:
143143
pwd
144144
cp target/release/czkawka_gui AppDir/usr/bin
145145
./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
146-
./appimagetool --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 20 \
146+
./appimagetool-x86_64.AppImage --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 20 \
147147
-u "gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|czkawka|latest|*.AppImage.zsync" \
148148
./AppDir
149149

Cargo.lock

+25-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Changelog.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@
22

33
### Core
44

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

1218
### Krokiet
1319

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

1723
### GTK GUI
1824

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

2127
### CLI
2228

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

2533
## Version 7.0.0 - 19.02.2024r
2634

ci_tester/src/main.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn main() {
3333

3434
for _ in 0..ATTEMPTS {
3535
test_empty_files();
36+
test_big_files();
3637
test_smallest_files();
3738
test_biggest_files();
3839
test_empty_folders();
@@ -373,6 +374,11 @@ fn test_empty_files() {
373374
run_test(&["empty-files", "-d", "TestFiles", "-D"], vec!["EmptyFile"], vec![], vec![]);
374375
}
375376

377+
fn test_big_files() {
378+
info!("test_big_files");
379+
run_test(&["big", "-d", "TestFiles", "-n", "2", "-D"], vec!["Music/M4.mp3", "Videos/V3.webm"], vec![], vec![]);
380+
}
381+
376382
////////////////////////////////////
377383
////////////////////////////////////
378384
/////////HELPER FUNCTIONS///////////
@@ -454,8 +460,7 @@ fn collect_all_files_and_dirs(dir: &str) -> std::io::Result<CollectedFiles> {
454460
let mut symlinks = BTreeSet::new();
455461

456462
let mut folders_to_check = vec![dir.to_string()];
457-
while !folders_to_check.is_empty() {
458-
let folder = folders_to_check.pop().expect("Should not fail in tests");
463+
while let Some(folder) = folders_to_check.pop() {
459464
let rd = fs::read_dir(folder)?;
460465
for entry in rd {
461466
let entry = entry?;
@@ -470,7 +475,7 @@ fn collect_all_files_and_dirs(dir: &str) -> std::io::Result<CollectedFiles> {
470475
} else if file_type.is_file() {
471476
files.insert(path_str);
472477
} else {
473-
panic!("Unknown type of file {path_str:?}");
478+
panic!("Unknown type of file {path_str}");
474479
}
475480
}
476481
}

czkawka_cli/src/main.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ fn main() {
6565
})
6666
.expect("Failed to spawn calculation thread");
6767
ctrlc::set_handler(move || {
68-
println!("Get Sender");
69-
stop_sender.send(()).expect("Could not send signal on channel.");
68+
println!("Get Ctrl+C signal, stopping...");
69+
if let Err(e) = stop_sender.send(()) {
70+
eprintln!("Failed to send stop signal {e}(it is possible that the program is already stopped)");
71+
};
7072
})
7173
.expect("Error setting Ctrl-C handler");
7274

@@ -348,9 +350,8 @@ fn save_and_print_results<T: CommonData + PrintResults>(component: &mut T, commo
348350
}
349351
}
350352

351-
if !cfg!(debug_assertions) {
352-
component.print_results_to_output();
353-
}
353+
component.print_results_to_output();
354+
354355
component.get_text_messages().print_messages();
355356
}
356357

czkawka_core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ os_info = { version = "3", default-features = false }
8181
log = "0.4.22"
8282
handsome_logger = "0.8"
8383
fun_time = { version = "0.3", features = ["log"] }
84+
itertools = "0.13"
8485

85-
[target.'cfg(windows)'.dependencies]
8686
# 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!
8787
# Warning by CalunVier 2024.7.15
88+
[target.'cfg(windows)'.dependencies]
8889
file-id = "=0.2.1"
8990

9091
[build-dependencies]

czkawka_core/src/bad_extensions.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ const WORKAROUNDS: &[(&str, &str)] = &[
103103
("pptx", "ppsx"), // Powerpoint
104104
("sh", "bash"), // Linux
105105
("sh", "guess"), // GNU
106+
("sh", "lua"), // Lua
107+
("sh", "js"), // Javascript
106108
("sh", "pl"), // Gnome/Linux
107109
("sh", "pm"), // Gnome/Linux
108110
("sh", "py"), // Python
@@ -268,10 +270,6 @@ impl BadExtensions {
268270

269271
let mut hashmap_workarounds: HashMap<&str, Vec<&str>> = Default::default();
270272
for (proper, found) in WORKAROUNDS {
271-
// 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
272-
// if hashmap_workarounds.contains_key(found) {
273-
// panic!("Already have {} key", found);
274-
// }
275273
hashmap_workarounds.entry(found).or_default().push(proper);
276274
}
277275

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

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

447445
Ok(())

czkawka_core/src/big_file.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum SearchMode {
1717
SmallestFiles,
1818
}
1919

20-
#[derive(Default)]
20+
#[derive(Debug, Default)]
2121
pub struct Info {
2222
pub number_of_real_files: usize,
2323
}
@@ -126,8 +126,8 @@ impl DebugPrint for BigFile {
126126
}
127127

128128
println!("### INDIVIDUAL DEBUG PRINT ###");
129-
println!("Big files size {} in {} groups", self.information.number_of_real_files, self.big_files.len());
130-
println!("Number of files to check - {:?}", self.get_params().number_of_files_to_check);
129+
println!("Info: {:?}", self.information);
130+
println!("Number of files to check - {}", self.get_params().number_of_files_to_check);
131131
self.debug_print_common();
132132
println!("-----------------------------------------");
133133
}
@@ -150,7 +150,13 @@ impl PrintResults for BigFile {
150150
writeln!(writer, "{} the smallest files.\n\n", self.information.number_of_real_files)?;
151151
}
152152
for file_entry in &self.big_files {
153-
writeln!(writer, "{} ({}) - {:?}", format_size(file_entry.size, BINARY), file_entry.size, file_entry.path)?;
153+
writeln!(
154+
writer,
155+
"{} ({}) - \"{}\"",
156+
format_size(file_entry.size, BINARY),
157+
file_entry.size,
158+
file_entry.path.to_string_lossy()
159+
)?;
154160
}
155161
} else {
156162
writeln!(writer, "Not found any files.")?;

czkawka_core/src/broken_files.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::common::{
99
check_if_stop_received, create_crash_message, prepare_thread_handler_common, send_info_and_wait_for_ending_all_threads, AUDIO_FILES_EXTENSIONS,
1010
IMAGE_RS_BROKEN_FILES_EXTENSIONS, PDF_FILES_EXTENSIONS, ZIP_FILES_EXTENSIONS,
1111
};
12-
use crate::common_cache::{get_broken_files_cache_file, load_cache_from_file_generalized_by_path, save_cache_to_file_generalized};
12+
use crate::common_cache::{extract_loaded_cache, get_broken_files_cache_file, load_cache_from_file_generalized_by_path, save_cache_to_file_generalized};
1313
use crate::common_dir_traversal::{DirTraversalBuilder, DirTraversalResult, FileEntry, ToolType};
1414
use crate::common_tool::{CommonData, CommonToolData, DeleteMethod};
1515
use crate::common_traits::*;
@@ -284,13 +284,7 @@ impl BrokenFiles {
284284
self.get_text_messages_mut().extend_with_another_messages(messages);
285285
loaded_hash_map = loaded_items.unwrap_or_default();
286286

287-
for (name, file_entry) in files_to_check {
288-
if let Some(cached_file_entry) = loaded_hash_map.get(&name) {
289-
records_already_cached.insert(name, cached_file_entry.clone());
290-
} else {
291-
non_cached_files_to_check.insert(name, file_entry);
292-
}
293-
}
287+
extract_loaded_cache(&loaded_hash_map, files_to_check, &mut records_already_cached, &mut non_cached_files_to_check);
294288
} else {
295289
loaded_hash_map = Default::default();
296290
non_cached_files_to_check = files_to_check;
@@ -421,7 +415,7 @@ impl PrintResults for BrokenFiles {
421415
if !self.broken_files.is_empty() {
422416
writeln!(writer, "Found {} broken files.", self.information.number_of_broken_files)?;
423417
for file_entry in &self.broken_files {
424-
writeln!(writer, "{:?} - {}", file_entry.path, file_entry.error_string)?;
418+
writeln!(writer, "\"{}\" - {}", file_entry.path.to_string_lossy(), file_entry.error_string)?;
425419
}
426420
} else {
427421
write!(writer, "Not found any broken files.")?;
@@ -462,7 +456,7 @@ fn check_extension_availability(
462456
} else if pdf_extensions.contains(&extension_lowercase.as_str()) {
463457
TypeOfFile::PDF
464458
} else {
465-
eprintln!("File with unknown extension: {full_name:?} - {extension_lowercase}");
459+
eprintln!("File with unknown extension: \"{}\" - {extension_lowercase}", full_name.to_string_lossy());
466460
debug_assert!(false, "File with unknown extension");
467461
TypeOfFile::Unknown
468462
}

0 commit comments

Comments
 (0)