From 8834ee8f542c1c436223af541809773938542fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sat, 18 Nov 2023 22:36:20 +0100 Subject: [PATCH] Changes --- .github/workflows/linux_cli_eyra.yml | 53 +++++++++++++++++++ Changelog.md | 6 ++- czkawka_core/src/bad_extensions.rs | 2 +- czkawka_core/src/broken_files.rs | 2 +- czkawka_core/src/common_traits.rs | 6 +-- czkawka_core/src/duplicate.rs | 7 ++- czkawka_core/src/temporary.rs | 2 +- czkawka_gui/i18n/en/czkawka_gui.ftl | 2 +- .../src/connect_things/connect_button_save.rs | 13 ++++- czkawka_gui/src/tests.rs | 2 +- krokiet/README.md | 14 ++--- krokiet/src/connect_delete.rs | 4 -- 12 files changed, 88 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/linux_cli_eyra.yml diff --git a/.github/workflows/linux_cli_eyra.yml b/.github/workflows/linux_cli_eyra.yml new file mode 100644 index 0000000..63d7357 --- /dev/null +++ b/.github/workflows/linux_cli_eyra.yml @@ -0,0 +1,53 @@ +name: 🐧 Linux CLI Eyra +on: + push: + pull_request: + schedule: + - cron: '0 0 * * 2' + +env: + CARGO_TERM_COLOR: always + +jobs: + linux-cli: + strategy: + matrix: + toolchain: [ nightly ] + type: [ release ] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - name: Install basic libraries + run: sudo apt-get update; sudo apt install -y + + - name: Setup rust version + run: rustup default ${{ matrix.toolchain }} + + - name: Add eyra + run: | + cd czkawka_cli + cargo add eyra --rename=std + echo 'fn main() { println!("cargo:rustc-link-arg=-nostartfiles"); }' > build.rs + cd .. + + - name: Build Release + run: cargo build --release --bin czkawka_cli + if: ${{ (matrix.type == 'release') }} + + - name: Store Linux CLI + uses: actions/upload-artifact@v3 + with: + name: czkawka_cli-${{ runner.os }}-${{ matrix.toolchain }} + path: target/release/czkawka_cli + if: ${{ matrix.type == 'release' }} + + - name: Linux Regression Test + run: | + wget https://github.com/qarmin/czkawka/releases/download/6.0.0/TestFiles.zip + cd ci_tester + cargo build --release + cd .. + + ci_tester/target/release/ci_tester target/release/czkawka_cli + if: ${{ matrix.type == 'release' }} diff --git a/Changelog.md b/Changelog.md index f75055d..c8be051 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,15 +1,17 @@ ## Version 7.0.0 - ? ### GTK GUI -- Added drag&drop support for included/excluded folders - [#1102](https://github.com/qarmin/czkawka/pull/1102) +- Added drag&drop support for included/excluded folders - [#1106](https://github.com/qarmin/czkawka/pull/1106) ### CLI +- Providing full static rust binary with [Eyra](https://github.com/sunfishcode/eyra) - [#1102](https://github.com/qarmin/czkawka/pull/1102) ### Krokiet GUI - Initial release of new gui - [#1102](https://github.com/qarmin/czkawka/pull/1102) ### Core - Using normal crossbeam channels instead of asyncio tokio channel - [#1102](https://github.com/qarmin/czkawka/pull/1102) -- Fixed tool type when using progress of empty directories +- Fixed tool type when using progress of empty directories - [#1102](https://github.com/qarmin/czkawka/pull/1102) +- Fixed missing json support in saving size and name - [#1102](https://github.com/qarmin/czkawka/pull/1102) ## Version 6.1.0 - 15.10.2023r - BREAKING CHANGE - Changed cache saving method, deduplicated, optimized and simplified procedure(all files needs to be hashed again) - [#1072](https://github.com/qarmin/czkawka/pull/1072), [#1086](https://github.com/qarmin/czkawka/pull/1086) diff --git a/czkawka_core/src/bad_extensions.rs b/czkawka_core/src/bad_extensions.rs index 2b30b4d..429d699 100644 --- a/czkawka_core/src/bad_extensions.rs +++ b/czkawka_core/src/bad_extensions.rs @@ -160,7 +160,7 @@ const WORKAROUNDS: &[(&str, &str)] = &[ ("exe", "xls"), // Not sure why xls is not recognized ]; -#[derive(Clone, Serialize)] +#[derive(Clone, Serialize, Debug)] pub struct BadFileEntry { pub path: PathBuf, pub modified_date: u64, diff --git a/czkawka_core/src/broken_files.rs b/czkawka_core/src/broken_files.rs index 5c56845..6bd24b8 100644 --- a/czkawka_core/src/broken_files.rs +++ b/czkawka_core/src/broken_files.rs @@ -26,7 +26,7 @@ use crate::common_dir_traversal::{common_get_entry_data_metadata, common_read_di use crate::common_tool::{CommonData, CommonToolData, DeleteMethod}; use crate::common_traits::*; -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize, Debug)] pub struct FileEntry { pub path: PathBuf, pub modified_date: u64, diff --git a/czkawka_core/src/common_traits.rs b/czkawka_core/src/common_traits.rs index 13a3da5..27aaebd 100644 --- a/czkawka_core/src/common_traits.rs +++ b/czkawka_core/src/common_traits.rs @@ -35,7 +35,7 @@ pub trait PrintResults { fn save_results_to_file_as_json(&self, file_name: &str, pretty_print: bool) -> std::io::Result<()>; - fn save_results_to_file_as_json_internal(&self, file_name: &str, item_to_serialize: &T, pretty_print: bool) -> std::io::Result<()> { + fn save_results_to_file_as_json_internal(&self, file_name: &str, item_to_serialize: &T, pretty_print: bool) -> std::io::Result<()> { if pretty_print { self.save_results_to_file_as_json_pretty(file_name, item_to_serialize) } else { @@ -44,7 +44,7 @@ pub trait PrintResults { } #[fun_time(message = "save_results_to_file_as_json_pretty", level = "debug")] - fn save_results_to_file_as_json_pretty(&self, file_name: &str, item_to_serialize: &T) -> std::io::Result<()> { + fn save_results_to_file_as_json_pretty(&self, file_name: &str, item_to_serialize: &T) -> std::io::Result<()> { let file_handler = File::create(file_name)?; let mut writer = BufWriter::new(file_handler); serde_json::to_writer_pretty(&mut writer, item_to_serialize)?; @@ -52,7 +52,7 @@ pub trait PrintResults { } #[fun_time(message = "save_results_to_file_as_json_compact", level = "debug")] - fn save_results_to_file_as_json_compact(&self, file_name: &str, item_to_serialize: &T) -> std::io::Result<()> { + fn save_results_to_file_as_json_compact(&self, file_name: &str, item_to_serialize: &T) -> std::io::Result<()> { let file_handler = File::create(file_name)?; let mut writer = BufWriter::new(file_handler); serde_json::to_writer(&mut writer, item_to_serialize)?; diff --git a/czkawka_core/src/duplicate.rs b/czkawka_core/src/duplicate.rs index 7946fe9..de47fcf 100644 --- a/czkawka_core/src/duplicate.rs +++ b/czkawka_core/src/duplicate.rs @@ -1160,11 +1160,14 @@ impl PrintResults for DuplicateFinder { Ok(()) } + // TODO - check if is possible to save also data in header about size and name in SizeName mode - https://github.com/qarmin/czkawka/issues/1137 fn save_results_to_file_as_json(&self, file_name: &str, pretty_print: bool) -> io::Result<()> { if self.get_use_reference() { match self.check_method { CheckingMethod::Name => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_names_referenced, pretty_print), - CheckingMethod::SizeName => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size_names_referenced, pretty_print), + CheckingMethod::SizeName => { + self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size_names_referenced.values().collect::>(), pretty_print) + } CheckingMethod::Size => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size_referenced, pretty_print), CheckingMethod::Hash => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_hashes_referenced, pretty_print), _ => panic!(), @@ -1172,7 +1175,7 @@ impl PrintResults for DuplicateFinder { } else { match self.check_method { CheckingMethod::Name => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_names, pretty_print), - CheckingMethod::SizeName => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size_names, pretty_print), + CheckingMethod::SizeName => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size_names.values().collect::>(), pretty_print), CheckingMethod::Size => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_size, pretty_print), CheckingMethod::Hash => self.save_results_to_file_as_json_internal(file_name, &self.files_with_identical_hashes, pretty_print), _ => panic!(), diff --git a/czkawka_core/src/temporary.rs b/czkawka_core/src/temporary.rs index ac17539..64dc78b 100644 --- a/czkawka_core/src/temporary.rs +++ b/czkawka_core/src/temporary.rs @@ -32,7 +32,7 @@ const TEMP_EXTENSIONS: &[&str] = &[ ".partial", ]; -#[derive(Clone, Serialize)] +#[derive(Clone, Serialize, Debug)] pub struct FileEntry { pub path: PathBuf, pub modified_date: u64, diff --git a/czkawka_gui/i18n/en/czkawka_gui.ftl b/czkawka_gui/i18n/en/czkawka_gui.ftl index 70d7780..68f1182 100644 --- a/czkawka_gui/i18n/en/czkawka_gui.ftl +++ b/czkawka_gui/i18n/en/czkawka_gui.ftl @@ -544,7 +544,7 @@ move_files_title_dialog = Choose folder to which you want to move duplicated fil move_files_choose_more_than_1_path = Only one path may be selected to be able to copy their duplicated files, selected {$path_number}. move_stats = Properly moved {$num_files}/{$all_files} items -save_results_to_file = Saved results both to txt and json files. +save_results_to_file = Saved results both to txt and json files into {$name} folder. search_not_choosing_any_music = ERROR: You must select at least one checkbox with music searching types. search_not_choosing_any_broken_files = ERROR: You must select at least one checkbox with type of checked broken files. diff --git a/czkawka_gui/src/connect_things/connect_button_save.rs b/czkawka_gui/src/connect_things/connect_button_save.rs index e407e08..c06e5c4 100644 --- a/czkawka_gui/src/connect_things/connect_button_save.rs +++ b/czkawka_gui/src/connect_things/connect_button_save.rs @@ -1,5 +1,6 @@ use std::cell::RefCell; use std::collections::HashMap; +use std::env; use std::rc::Rc; use gtk4::prelude::*; @@ -10,6 +11,7 @@ use czkawka_core::common_traits::PrintResults; use crate::flg; use crate::gui_structs::gui_data::GuiData; use crate::help_functions::BottomButtonsEnum; +use crate::localizer_core::generate_translation_hashmap; use crate::notebook_enums::*; pub fn connect_button_save(gui_data: &GuiData) { @@ -44,10 +46,15 @@ pub fn connect_button_save(gui_data: &GuiData) { NotebookMainEnum::BadExtensions => shared_bad_extensions_state.borrow().save_all_in_one("results_bad_extensions"), }; + let current_path = match env::current_dir() { + Ok(t) => t.to_string_lossy().to_string(), + Err(_) => "".to_string(), + }; + match result { Ok(()) => (), Err(e) => { - entry_info.set_text(&format!("Failed to save results to file {e}")); + entry_info.set_text(&format!("Failed to save results to folder {current_path}, reason {e}")); return; } } @@ -57,6 +64,7 @@ pub fn connect_button_save(gui_data: &GuiData) { &shared_buttons, &entry_info, &buttons_save_clone, + current_path, ); }); } @@ -66,8 +74,9 @@ fn post_save_things( shared_buttons: &Rc>>>, entry_info: &Entry, buttons_save: &Button, + current_path: String, ) { - entry_info.set_text(&flg!("save_results_to_file")); + entry_info.set_text(&flg!("save_results_to_file", generate_translation_hashmap(vec![("name", current_path),]))); // Set state { buttons_save.hide(); diff --git a/czkawka_gui/src/tests.rs b/czkawka_gui/src/tests.rs index 522f0fa..e43b96c 100644 --- a/czkawka_gui/src/tests.rs +++ b/czkawka_gui/src/tests.rs @@ -6,7 +6,7 @@ use crate::GuiData; pub fn validate_notebook_data(gui_data: &GuiData) { // Test treeviews names, each treeview should have set name same as variable name - for item in gui_data.main_notebook.get_main_tree_views().iter() { + for item in &gui_data.main_notebook.get_main_tree_views() { // println!("Checking {} element", i); get_notebook_enum_from_tree_view(item); diff --git a/krokiet/README.md b/krokiet/README.md index 4ca94c1..a0899f7 100644 --- a/krokiet/README.md +++ b/krokiet/README.md @@ -127,13 +127,13 @@ SLINT_STYLE=material-dark cargo run -- --path . There are multiple reasons why I decided to use Slint as toolkit for Krokiet over other toolkits. -| Toolkit | Pros | Cons | -|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Gtk 4 | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows
- Cambalache can be used to create graphically gui
- Good gtk4-rs bindings(but sometimes not really intuitive) | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows
- Forcing the use of a specific gui creation style
- Strange crashes, not working basic features, etc.(again, mostly on windows)
- Forcing to use bugged/outdated but dynamically loaded version of libraries on linux (e.g. 4.6 on Ubuntu 22.04) - not all fixes are backported | -| Qt | - QML support - simplify creating of gui from code it is easy to use and powerful
- Very flexible framework
- Typescript/javascript <=> qml interoperability
- Probably the most mature GUI library | - New and limited qt bindings
- Big cross compilation problems and hard to setup on non windows platforms
- Very easy to create and use invalid state in QML(unexpected null/undefined values etc.)
- Commercial license or GPL | -| Slint | - Internal language is compiled to native code
- Live gui preview with Vscode/Vscodium without needing to use rust
- Full rust solution - easy to compile/cross compile, minimal runtime requirements | - Internal .slint language is more limited than QML(javascript flexibility is big pl)
- Out of bounds and similar errors are quietly being corrected instead printing error - this can lead to hard to debug problems
- Commercial license or GPL(is available also different
Popup windows almost not exists
Internal widgets are almost not customizable and usually quite limited ) | -| Iced | - ~100% rust code - so compilation is simple
- Elm architecture - simple to understand | - Mostly maintained by one person - slows down fixing bugs and implementing new features
- GUI can be created only from rust code, which really is bad for creating complex GUIs(mostly due rust compile times) and this is also
- Docs are almost non-existent | -| Tauri | - Easy to create ui(at least for web developers) - uses html/css/js
- Quite portable | - Webview dependency - it is not really lightweight and can be hard to compile on some platforms
- Cannot select directory - file chooser only can choose files - small thing but important for me
- Not very performant Rust <=> Javascript communication | +| Toolkit | Pros | Cons | +|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Gtk 4 | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows
- Cambalache can be used to create graphically gui
- Good gtk4-rs bindings(but sometimes not really intuitive) | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows
- Forcing the use of a specific gui creation style
- Strange crashes, not working basic features, etc.(again, mostly on windows)
- Forcing to use bugged/outdated but dynamically loaded version of libraries on linux (e.g. 4.6 on Ubuntu 22.04) - not all fixes are backported | +| Qt | - QML support - simplify creating of gui from code it is easy to use and powerful
- Very flexible framework
- Typescript/javascript <=> qml interoperability
- Probably the most mature GUI library | - New and limited qt bindings
- Big cross compilation problems and hard to setup on non windows platforms
- Very easy to create and use invalid state in QML(unexpected null/undefined values etc.)
- Commercial license or GPL | +| Slint | - Internal language is compiled to native code
- Live gui preview with Vscode/Vscodium without needing to use rust
- Full rust solution - easy to compile/cross compile, minimal runtime requirements | - Internal .slint language is more limited than QML(javascript flexibility is big pl)
- Out of bounds and similar errors are quietly being corrected instead printing error - this can lead to hard to debug problems
- Commercial license or GPL(is available also different
- Popup windows almost not exists
- Internal widgets are almost not customizable and usually quite limited ) | +| Iced | - ~100% rust code - so compilation is simple
- Elm architecture - simple to understand | - Mostly maintained by one person - slows down fixing bugs and implementing new features
- GUI can be created only from rust code, which really is bad for creating complex GUIs(mostly due rust compile times) and this is also
- Docs are almost non-existent | +| Tauri | - Easy to create ui(at least for web developers) - uses html/css/js
- Quite portable | - Webview dependency - it is not really lightweight and can be hard to compile on some platforms
- Cannot select directory - file chooser only can choose files - small thing but important for me
- Not very performant Rust <=> Javascript communication | Since I don't have time to create really complex and good looking GUI, I needed a helper tool to create GUI not from Rust(I don't want to use different language, because this will make communication with czkawka_core harder) so I decided diff --git a/krokiet/src/connect_delete.rs b/krokiet/src/connect_delete.rs index 94a06c2..46ab2eb 100644 --- a/krokiet/src/connect_delete.rs +++ b/krokiet/src/connect_delete.rs @@ -1,5 +1,3 @@ -use std::borrow::Borrow; - use slint::{ComponentHandle, Model, ModelRc, VecModel}; use crate::{Callabler, CurrentTab, MainListModel, MainWindow}; @@ -16,7 +14,6 @@ pub fn connect_delete_button(app: &MainWindow) { CurrentTab::EmptyFolders => app.get_empty_folder_model(), CurrentTab::SimilarImages => app.get_similar_images_model(), CurrentTab::EmptyFiles => app.get_empty_files_model(), - _ => panic!(), }; let new_model = handle_delete_items(&model, active_tab == CurrentTab::EmptyFolders); @@ -26,7 +23,6 @@ pub fn connect_delete_button(app: &MainWindow) { CurrentTab::EmptyFolders => app.set_empty_folder_model(new_model), CurrentTab::SimilarImages => app.set_similar_images_model(new_model), CurrentTab::EmptyFiles => app.set_empty_files_model(new_model), - _ => panic!(), } } });