From 4d90e3170e3ad269d483f6c28667a13600ba553e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Wed, 21 Oct 2020 16:44:09 -0400 Subject: [PATCH] Remove warnings about non existent directories in Windows (#79) --- czkawka_core/src/common_directory.rs | 2 +- czkawka_gui/src/main.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/czkawka_core/src/common_directory.rs b/czkawka_core/src/common_directory.rs index 56a0e31..7437d08 100644 --- a/czkawka_core/src/common_directory.rs +++ b/czkawka_core/src/common_directory.rs @@ -84,7 +84,7 @@ impl Directories { continue; } if !directory.exists() { - text_messages.warnings.push(format!("Excluded Directory Warning: Provided folder path must exits, ignoring {}", directory.display())); + // text_messages.warnings.push(format!("Excluded Directory Warning: Provided folder path must exits, ignoring {}", directory.display())); continue; } if !directory.is_dir() { diff --git a/czkawka_gui/src/main.rs b/czkawka_gui/src/main.rs index 6f46957..bb559b5 100644 --- a/czkawka_gui/src/main.rs +++ b/czkawka_gui/src/main.rs @@ -366,15 +366,14 @@ fn main() { let current_dir: String = match env::current_dir() { Ok(t) => t.to_str().unwrap().to_string(), Err(_) => { - #[cfg(target_family = "unix")] - { + if cfg!(target_family = "unix") { println!("Failed to read current directory, setting /home instead"); "/home".to_string() - } - #[cfg(target_family = "windows")] - { + } else if cfg!(target_family = "windows") { println!("Failed to read current directory, setting C:\\ instead"); "C:\\".to_string() + } else { + "".to_string() } } }; @@ -408,13 +407,11 @@ fn main() { } // Set Excluded Items { - #[cfg(target_family = "unix")] - { - entry_excluded_items.set_text("*/.git/,*/node_modules/,*/lost+found/"); + if cfg!(target_family = "unix") { + entry_excluded_items.set_text("*/.git/*,*/node_modules/*,*/lost+found/*"); } - #[cfg(target_family = "windows")] - { - entry_excluded_items.set_text("*\\.git\\,*\\node_modules\\,*:\\Windows\\,:/Windows/"); + if cfg!(target_family = "windows") { + entry_excluded_items.set_text("*/.git/*,*/node_modules/*,*/lost+found/*,*:/windows/*"); } } } @@ -912,7 +909,10 @@ fn main() { for path_to_delete in vec_path_to_delete { let mut vec_tree_path_to_delete: Vec = Vec::new(); - let iter = list_store.get_iter_first().unwrap(); + let iter = match list_store.get_iter_first() { + Some(t) => t, + None => break, + }; let mut take_child_mode = false; // When original image is searched one, we must remove all occurences of its children let mut prepared_for_delete; loop {