summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2023-07-23 15:19:31 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2023-07-23 15:20:01 -0400
commit461f09532ca9cb8b104b03927843e48779747d7d (patch)
tree5ebe5c1a9a4c2b2992b2a6bcce74c1f82be3f117
parenta8dca77e39f01637c735b7eec2ea9bf00cbc9af3 (diff)
fix recycle_bin feature not disabling references to trash
-rw-r--r--src/error/error_kind.rs2
-rw-r--r--src/error/error_type.rs1
-rw-r--r--src/io/io_worker.rs10
3 files changed, 12 insertions, 1 deletions
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<std::env::VarError> for JoshutoError {
}
}
+#[cfg(feature = "recycle_bin")]
impl From<trash::Error> 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<P>(paths: &[P]) -> std::io::Result<()>
where
P: AsRef<path::Path>,