From 461f09532ca9cb8b104b03927843e48779747d7d Mon Sep 17 00:00:00 2001 From: Jeff Zhao Date: Sun, 23 Jul 2023 15:19:31 -0400 Subject: fix recycle_bin feature not disabling references to trash --- src/error/error_kind.rs | 2 ++ src/error/error_type.rs | 1 + src/io/io_worker.rs | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/error/error_kind.rs b/src/error/error_kind.rs index a03cd13..7260e2d 100644 --- a/src/error/error_kind.rs +++ b/src/error/error_kind.rs @@ -13,6 +13,8 @@ pub enum JoshutoErrorKind { ParseError, ClipboardError, TomlDeError(toml::de::Error), + + #[cfg(feature = "recycle_bin")] TrashError, Glob, diff --git a/src/error/error_type.rs b/src/error/error_type.rs index 31ffa23..4e2eaad 100644 --- a/src/error/error_type.rs +++ b/src/error/error_type.rs @@ -56,6 +56,7 @@ impl From for JoshutoError { } } +#[cfg(feature = "recycle_bin")] impl From for JoshutoError { fn from(err: trash::Error) -> Self { let cause = err.to_string(); diff --git a/src/io/io_worker.rs b/src/io/io_worker.rs index 42a3ef5..3be08e6 100644 --- a/src/io/io_worker.rs +++ b/src/io/io_worker.rs @@ -200,11 +200,17 @@ impl IoWorkerThread { total_bytes, total_bytes, ); + #[cfg(feature = "recycle_bin")] if self.options.permanently { remove_files(&self.paths)?; } else { trash_files(&self.paths)?; } + #[cfg(not(feature = "recycle_bin"))] + { + remove_files(&self.paths)?; + } + Ok(progress) } } @@ -323,7 +329,8 @@ pub fn recursive_cut( } } -fn trash_error_to_io_error(err: trash::Error) -> std::io::Error { +#[cfg(feature = "recycle_bin")] +fn trash_error_to_io_error(err: ::Error) -> std::io::Error { match err { trash::Error::Unknown { description } => { std::io::Error::new(std::io::ErrorKind::Other, description) @@ -351,6 +358,7 @@ where Ok(()) } +#[cfg(feature = "recycle_bin")] fn trash_files

(paths: &[P]) -> std::io::Result<()> where P: AsRef, -- cgit v1.2.3