feat: make trash optional

This commit is contained in:
sxyazi 2023-09-18 07:46:42 +08:00
parent c540542da4
commit 2447917ac7
No known key found for this signature in database
2 changed files with 17 additions and 10 deletions

View file

@ -26,9 +26,13 @@ syntect = "^5"
tokio = { version = "^1", features = [ "parking_lot", "macros", "rt-multi-thread", "sync", "time", "fs", "process", "io-std", "io-util" ] } tokio = { version = "^1", features = [ "parking_lot", "macros", "rt-multi-thread", "sync", "time", "fs", "process", "io-std", "io-util" ] }
tokio-stream = "^0" tokio-stream = "^0"
tracing = "^0" tracing = "^0"
trash = "^3" trash = { version = "^3", optional = true }
unicode-width = "^0" unicode-width = "^0"
yazi-prebuild = "^0" yazi-prebuild = "^0"
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
clipboard-win = "^4" clipboard-win = "^4"
[features]
trash_bin = [ "trash" ]
default = [ "trash_bin" ]

View file

@ -152,6 +152,8 @@ impl File {
self.sch.send(TaskOp::Adv(task.id, 1, task.length))? self.sch.send(TaskOp::Adv(task.id, 1, task.length))?
} }
FileOp::Trash(task) => { FileOp::Trash(task) => {
#[cfg(feature = "trash_bin")]
{
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
use trash::{macos::{DeleteMethod, TrashContextExtMacos}, TrashContext}; use trash::{macos::{DeleteMethod, TrashContextExtMacos}, TrashContext};
@ -163,6 +165,7 @@ impl File {
{ {
trash::delete(&task.target)?; trash::delete(&task.target)?;
} }
}
self.sch.send(TaskOp::Adv(task.id, 1, task.length))?; self.sch.send(TaskOp::Adv(task.id, 1, task.length))?;
} }
} }