summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSkyler Hawthorne <skyler@dead10ck.dev>2024-05-06 23:22:52 -0400
committerSkyler Hawthorne <skyler@dead10ck.dev>2024-05-07 09:00:55 -0400
commitf1b0dabdcdd9311ecba28555d0674e7dcb25fd3a (patch)
tree3b04bf64cbe4a0945b8f0bb42c526d7081f10765
parent100de927b467bba0760805ecfb790582ed9ff00a (diff)
fix builds on android
Since #803 introduced a dependency on the trash crate, broot does not compile any more on Android. This change makes the trash crate only pulled in on platforms which support it, and otherwise the trash command displays an error.
-rw-r--r--Cargo.toml4
-rwxr-xr-xcompile-all-targets.sh2
-rw-r--r--src/browser/browser_state.rs5
-rw-r--r--src/stage/stage_state.rs5
4 files changed, 14 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 936db4e..d7728de 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,8 +17,10 @@ exclude = ["website", "broot*.zip"]
[features]
default = []
+
clipboard = ["terminal-clipboard"]
kitty-csi-check = ["xterm-query"]
+trash = ["dep:trash"]
[dependencies]
ahash = { version = "0.8.3", features = ["serde"] }
@@ -62,7 +64,7 @@ termimad = "0.29.2"
terminal-clipboard = { version = "0.4.1", optional = true }
terminal-light = "1.4.0"
toml = "0.8"
-trash = "3.1.2"
+trash = { version = "3.1.2", optional = true }
umask = "2.1.0"
unicode-width = "0.1.10"
which = "4.4.0"
diff --git a/compile-all-targets.sh b/compile-all-targets.sh
index cd460cd..eb509c9 100755
--- a/compile-all-targets.sh
+++ b/compile-all-targets.sh
@@ -50,7 +50,7 @@ cross_build "ARM 32" "armv7-unknown-linux-gnueabihf" ""
cross_build "ARM 32 MUSL" "armv7-unknown-linux-musleabi" ""
cross_build "ARM 64" "aarch64-unknown-linux-gnu" ""
cross_build "ARM 64 MUSL" "aarch64-unknown-linux-musl" ""
-cross_build "Windows" "x86_64-pc-windows-gnu" "clipboard"
+cross_build "Windows" "x86_64-pc-windows-gnu" "clipboard,trash"
# cross_build "Android" "aarch64-linux-android" "clipboard" Doesn't work anymore - See https://github.com/Canop/broot/issues/565
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs
index ad9a6a2..82dbb49 100644
--- a/src/browser/browser_state.rs
+++ b/src/browser/browser_state.rs
@@ -632,6 +632,8 @@ impl PanelState for BrowserState {
Internal::trash => {
let path = self.displayed_tree().selected_line().path.to_path_buf();
info!("trash {:?}", &path);
+
+ #[cfg(feature = "trash")]
match trash::delete(&path) {
Ok(()) => CmdResult::RefreshState { clear_cache: true },
Err(e) => {
@@ -639,6 +641,9 @@ impl PanelState for BrowserState {
CmdResult::DisplayError(format!("trash error: {:?}", &e))
}
}
+
+ #[cfg(not(feature = "trash"))]
+ CmdResult::DisplayError("feature not enabled or platform does not support trash".into())
}
Internal::quit => CmdResult::Quit,
_ => self.on_internal_generic(
diff --git a/src/stage/stage_state.rs b/src/stage/stage_state.rs
index 0c70418..f1186b0 100644
--- a/src/stage/stage_state.rs
+++ b/src/stage/stage_state.rs
@@ -496,6 +496,8 @@ impl PanelState for StageState {
}
Internal::trash => {
info!("trash {} staged files", app_state.stage.len());
+
+ #[cfg(feature = "trash")]
match trash::delete_all(app_state.stage.paths()) {
Ok(()) => CmdResult::RefreshState { clear_cache: true },
Err(e) => {
@@ -503,6 +505,9 @@ impl PanelState for StageState {
CmdResult::DisplayError(format!("trash error: {:?}", &e))
}
}
+
+ #[cfg(not(feature = "trash"))]
+ CmdResult::DisplayError("feature not enabled or platform does not support trash".into())
}
_ => self.on_internal_generic(
w,