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

Add option to exclude files from other filesystems in GUI(Linux) #776

Merged
merged 4 commits into from
Jul 19, 2022
Merged
Changes from all commits
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
136 changes: 69 additions & 67 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Version 5.0.0 - ?.?.2022r
- GTK 4 port - [#466](https://github.com/qarmin/czkawka/pull/466)
- GUI ported to use GTK 4 - [#466](https://github.com/qarmin/czkawka/pull/466)
- Use multithreading and improved algorithm to compare image hashes - [#762](https://github.com/qarmin/czkawka/pull/762)
- Resize preview with window - [#466](https://github.com/qarmin/czkawka/pull/466)
- Fix removing only one item from list view - [#466](https://github.com/qarmin/czkawka/pull/466)
- Fix showing help command in duplicate CLI mode - [#720](https://github.com/qarmin/czkawka/pull/720)
- Fix freeze when not choosing any tag in similar music mode - [TODO]()
- Fix freeze when not choosing any tag in similar music mode - [#732](https://github.com/qarmin/czkawka/pull/732)
- Fix preview of files with non-lowercase extensions - [#694](https://github.com/qarmin/czkawka/pull/694)
- Read more tags from music files - [#705](https://github.com/qarmin/czkawka/pull/705)
- Improve checking for invalid extensions - [#705](https://github.com/qarmin/czkawka/pull/705), [#747](https://github.com/qarmin/czkawka/pull/747), [#749](https://github.com/qarmin/czkawka/pull/749)
@@ -15,6 +16,7 @@
- Improve Windows CI - [#749](https://github.com/qarmin/czkawka/pull/749)
- Ability to check for broken files by types - [#749](https://github.com/qarmin/czkawka/pull/749)
- Add heif and Webp files support - [#750](https://github.com/qarmin/czkawka/pull/750)
- Use in CLI Clap library instead StructOpt - [#759](https://github.com/qarmin/czkawka/pull/759)

## Version 4.1.0 - 24.04.2022r
- New mode - finding files whose content not match with their extension - [#678](https://github.com/qarmin/czkawka/pull/678)
5 changes: 3 additions & 2 deletions czkawka_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@ name = "czkawka_cli"
version = "4.1.0"
authors = ["Rafał Mikrut <mikrutrafal@protonmail.com>"]
edition = "2021"
rust-version = "1.60"
description = "CLI frontend of Czkawka"
license = "MIT"
homepage = "https://github.com/qarmin/czkawka"
repository = "https://github.com/qarmin/czkawka"

[dependencies]
clap = { version = "3.2.3", features = ["derive"]}
clap = { version = "3.2.12", features = ["derive"] }

# For enum types
image_hasher = "1.0.0"
@@ -21,4 +22,4 @@ features = []

[features]
default = []
heif = ["czkawka_core/heif"]
heif = ["czkawka_core/heif"]
21 changes: 11 additions & 10 deletions czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ name = "czkawka_core"
version = "4.1.0"
authors = ["Rafał Mikrut <mikrutrafal@protonmail.com>"]
edition = "2021"
rust-version = "1.60"
description = "Core of Czkawka app"
license = "MIT"
homepage = "https://github.com/qarmin/czkawka"
@@ -11,27 +12,27 @@ repository = "https://github.com/qarmin/czkawka"

[dependencies]
humansize = "1.1.1"
rayon = "1.5.1"
crossbeam-channel = "0.5.4"
rayon = "1.5.3"
crossbeam-channel = "0.5.5"

# For saving/loading config files to specific directories
directories-next = "2.0.0"

# Needed by similar images
image_hasher = "1.0.0"
bk-tree = "0.4.0"
image = "0.24.2"
image = "0.24.3"
hamming = "0.1.3"

# Needed by same music
bitflags = "1.3.2"
lofty="0.7.0"
lofty= "0.7.2"

# Futures - needed by async progress sender
futures = "0.3.21"

# Needed by broken files
zip = { version = "0.6.2", features=["aes-crypto", "bzip2", "deflate", "time"], default-features = false}
zip = { version = "0.6.2", features = ["aes-crypto", "bzip2", "deflate", "time"], default-features = false }
audio_checker = "0.1.0"
pdf = "0.7.2"

@@ -47,15 +48,15 @@ vid_dup_finder_lib = "0.1.0"
ffmpeg_cmdline_utils = "0.1.1"

# Saving/Loading Cache
serde = "1.0.137"
serde = "1.0.139"
bincode = "1.3.3"
serde_json = "1.0.81"
serde_json = "1.0.82"

# Language
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.4"
rust-embed = "6.4.0"
once_cell = "1.10.0"
once_cell = "1.13.0"

# Raw image files
rawloader = "0.37.1"
@@ -68,8 +69,8 @@ infer = "0.9.0"
num_cpus = "1.13.1"

libheif-rs = { version = "0.15.0", optional = true }
anyhow = { version = "1.0.57", optional = true }
anyhow = { version = "1.0.58", optional = true }

[features]
default = []
heif = ["dep:libheif-rs", "dep:anyhow"]
heif = ["dep:libheif-rs", "dep:anyhow"]
6 changes: 6 additions & 0 deletions czkawka_core/src/bad_extensions.rs
Original file line number Diff line number Diff line change
@@ -238,6 +238,12 @@ impl BadExtensions {
t => t,
};
}
#[cfg(target_family = "unix")]
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub const fn get_text_messages(&self) -> &Messages {
&self.text_messages
2 changes: 2 additions & 0 deletions czkawka_core/src/big_file.rs
Original file line number Diff line number Diff line change
@@ -133,6 +133,8 @@ impl BigFile {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

/// List of allowed extensions, only files with this extensions will be checking if are duplicates
pub fn set_allowed_extensions(&mut self, allowed_extensions: String) {
2 changes: 2 additions & 0 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
@@ -171,6 +171,8 @@ impl BrokenFiles {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) -> bool {
self.directories.set_included_directory(included_directory, &mut self.text_messages)
4 changes: 2 additions & 2 deletions czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ pub struct Directories {
pub excluded_directories: Vec<PathBuf>,
pub included_directories: Vec<PathBuf>,
pub reference_directories: Vec<PathBuf>,
#[cfg(target_family = "unix")]
exclude_other_filesystems: Option<bool>,
#[cfg(target_family = "unix")]
included_dev_ids: Vec<u64>,
@@ -181,7 +180,8 @@ impl Directories {
self.reference_directories.dedup();

// Optimize for duplicated included directories - "/", "/home". "/home/Pulpit" to "/"
if recursive_search {
// Do not use when not using recursive search or using
if recursive_search && !self.exclude_other_filesystems.unwrap_or(false) {
// This is only point which can't be done when recursive search is disabled.
let mut is_inside: bool;
for ed_checked in &self.excluded_directories {
2 changes: 2 additions & 0 deletions czkawka_core/src/duplicate.rs
Original file line number Diff line number Diff line change
@@ -271,6 +271,8 @@ impl DuplicateFinder {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) {
self.directories.set_included_directory(included_directory, &mut self.text_messages);
2 changes: 2 additions & 0 deletions czkawka_core/src/empty_files.rs
Original file line number Diff line number Diff line change
@@ -100,6 +100,8 @@ impl EmptyFiles {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) -> bool {
self.directories.set_included_directory(included_directory, &mut self.text_messages)
2 changes: 2 additions & 0 deletions czkawka_core/src/empty_folder.rs
Original file line number Diff line number Diff line change
@@ -71,6 +71,8 @@ impl EmptyFolder {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_excluded_items(&mut self, excluded_items: Vec<String>) {
self.excluded_items.set_excluded_items(excluded_items, &mut self.text_messages);
2 changes: 2 additions & 0 deletions czkawka_core/src/invalid_symlinks.rs
Original file line number Diff line number Diff line change
@@ -99,6 +99,8 @@ impl InvalidSymlinks {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) -> bool {
self.directories.set_included_directory(included_directory, &mut self.text_messages)
2 changes: 2 additions & 0 deletions czkawka_core/src/same_music.rs
Original file line number Diff line number Diff line change
@@ -199,6 +199,8 @@ impl SameMusic {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

/// Set included dir which needs to be relative, exists etc.
pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) {
5 changes: 4 additions & 1 deletion czkawka_core/src/similar_images.rs
Original file line number Diff line number Diff line change
@@ -216,6 +216,8 @@ impl SimilarImages {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_allowed_extensions(&mut self, allowed_extensions: String) {
self.allowed_extensions.set_allowed_extensions(allowed_extensions, &mut self.text_messages);
@@ -730,7 +732,8 @@ impl SimilarImages {
}

let number_of_processors = num_cpus::get();
let chunks: Vec<_> = all_hashes.chunks(all_hashes.len() / number_of_processors).collect();
let chunk_size = all_hashes.len() / number_of_processors;
let chunks: Vec<_> = if chunk_size > 0 { all_hashes.chunks(chunk_size).collect() } else { vec![&all_hashes] };

let parts: Vec<_> = chunks
.into_par_iter()
2 changes: 2 additions & 0 deletions czkawka_core/src/similar_videos.rs
Original file line number Diff line number Diff line change
@@ -170,6 +170,8 @@ impl SimilarVideos {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_minimal_file_size(&mut self, minimal_file_size: u64) {
self.minimal_file_size = match minimal_file_size {
2 changes: 2 additions & 0 deletions czkawka_core/src/temporary.rs
Original file line number Diff line number Diff line change
@@ -113,6 +113,8 @@ impl Temporary {
pub fn set_exclude_other_filesystems(&mut self, exclude_other_filesystems: bool) {
self.directories.set_exclude_other_filesystems(exclude_other_filesystems);
}
#[cfg(not(target_family = "unix"))]
pub fn set_exclude_other_filesystems(&mut self, _exclude_other_filesystems: bool) {}

pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>) -> bool {
self.directories.set_included_directory(included_directory, &mut self.text_messages)
23 changes: 12 additions & 11 deletions czkawka_gui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,20 +3,21 @@ name = "czkawka_gui"
version = "4.1.0"
authors = ["Rafał Mikrut <mikrutrafal@protonmail.com>"]
edition = "2021"
rust-version = "1.60"
description = "GTK frontend of Czkawka"
license = "MIT"
homepage = "https://github.com/qarmin/czkawka"
repository = "https://github.com/qarmin/czkawka"

[dependencies]
gdk4 = "0.4.7"
glib = "0.15.11"
gdk4 = "0.4.8"
glib = "0.15.12"

humansize = "1.1.1"
chrono = "0.4.19"

# Used for sending stop signal across threads
crossbeam-channel = "0.5.4"
crossbeam-channel = "0.5.5"

# To get informations about progress
futures = "0.3.21"
@@ -25,19 +26,19 @@ futures = "0.3.21"
directories-next = "2.0.0"

# For opening files
open = "3.0.1"
open = "3.0.2"

# To get image preview
image = "0.24.2"
image = "0.24.3"

# To be able to use custom select
regex = "1.5.5"
regex = "1.6.0"

# To get image_hasher types
image_hasher = "1.0.0"

# Move files to trash
trash = "2.1.4"
trash = "2.1.5"

# For moving files(why std::fs doesn't have such features)
fs_extra = "1.2.0"
@@ -46,14 +47,14 @@ fs_extra = "1.2.0"
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.4"
rust-embed = "6.4.0"
once_cell = "1.10.0"
once_cell = "1.13.0"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["combaseapi", "objbase", "shobjidl_core", "windef", "winerror", "wtypesbase", "winuser"] }

[dependencies.gtk4]
version = "0.4.7"
default-features = false # just in case
version = "0.4.8"
default-features = false
features = ["v4_6"]

[dependencies.czkawka_core]
@@ -63,4 +64,4 @@ features = []

[features]
default = []
heif = ["czkawka_core/heif"]
heif = ["czkawka_core/heif"]
6 changes: 6 additions & 0 deletions czkawka_gui/i18n/en/czkawka_gui.ftl
Original file line number Diff line number Diff line change
@@ -268,6 +268,12 @@ header_about_button_tooltip = Opens dialog with info about app.

# Settings
## General
settings_ignore_other_filesystems = Ignore other filesystems(only Linux)
settings_ignore_other_filesystems_tooltip =
ignores files that are not in the same file system as searched directories.

Works same like -xdev option in find command on Linux

settings_save_at_exit_button_tooltip = Save configuration to file when closing app.
settings_load_at_start_button_tooltip =
Load configuration from file when opening app.
12 changes: 7 additions & 5 deletions czkawka_gui/src/connect_things/connect_button_compare.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@ use image::DynamicImage;

use crate::flg;
use crate::gui_structs::gui_data::GuiData;
use crate::help_functions::{count_number_of_groups, get_all_children, get_full_name_from_path_name, get_max_file_name, get_pixbuf_from_dynamic_image, resize_pixbuf_dimension};
use crate::help_functions::{
count_number_of_groups, get_all_direct_children, get_full_name_from_path_name, get_max_file_name, get_pixbuf_from_dynamic_image, resize_pixbuf_dimension,
};
use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_info::{NotebookObject, NOTEBOOKS_INFO};

@@ -326,7 +328,7 @@ fn populate_groups_at_start(
*shared_image_cache.borrow_mut() = cache_all_images.clone();

let mut found = false;
for i in get_all_children(&scrolled_window_compare_choose_images.child().unwrap().downcast::<gtk4::Viewport>().unwrap()) {
for i in get_all_direct_children(&scrolled_window_compare_choose_images.child().unwrap().downcast::<gtk4::Viewport>().unwrap()) {
if i.widget_name() == "all_box" {
let gtk_box = i.downcast::<gtk4::Box>().unwrap();
update_bottom_buttons(&gtk_box, shared_using_for_preview, shared_image_cache);
@@ -618,13 +620,13 @@ fn update_bottom_buttons(
let left_tree_view = (*shared_using_for_preview.borrow()).0.clone().unwrap();
let right_tree_view = (*shared_using_for_preview.borrow()).1.clone().unwrap();

for (number, i) in get_all_children(all_gtk_box).into_iter().enumerate() {
for (number, i) in get_all_direct_children(all_gtk_box).into_iter().enumerate() {
let cache_tree_path = (*image_cache.borrow())[number].4.clone();
let is_chosen = cache_tree_path != right_tree_view && cache_tree_path != left_tree_view;

let bx = i.downcast::<gtk4::Box>().unwrap();
let smaller_bx = get_all_children(&bx)[0].clone().downcast::<gtk4::Box>().unwrap();
for items in get_all_children(&smaller_bx) {
let smaller_bx = get_all_direct_children(&bx)[0].clone().downcast::<gtk4::Box>().unwrap();
for items in get_all_direct_children(&smaller_bx) {
if let Ok(btn) = items.downcast::<gtk4::Button>() {
btn.set_sensitive(is_chosen);
}
Loading