Add empty trash, fixes #118
This commit is contained in:
parent
99c378873a
commit
1116eaa05a
5 changed files with 91 additions and 15 deletions
|
|
@ -18,6 +18,8 @@ pub enum Operation {
|
|||
Delete {
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
/// Empty the trash
|
||||
EmptyTrash,
|
||||
/// Move items
|
||||
Move {
|
||||
paths: Vec<PathBuf>,
|
||||
|
|
@ -100,6 +102,31 @@ impl Operation {
|
|||
.await;
|
||||
}
|
||||
}
|
||||
Self::EmptyTrash => {
|
||||
#[cfg(any(
|
||||
target_os = "windows",
|
||||
all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "android")
|
||||
)
|
||||
))]
|
||||
{
|
||||
tokio::task::spawn_blocking(|| {
|
||||
let items = trash::os_limited::list()?;
|
||||
trash::os_limited::purge_all(items)
|
||||
})
|
||||
.await
|
||||
.map_err(err_str)?
|
||||
.map_err(err_str)?;
|
||||
}
|
||||
let _ = msg_tx
|
||||
.lock()
|
||||
.await
|
||||
.send(Message::PendingProgress(id, 100.0))
|
||||
.await;
|
||||
}
|
||||
Self::Move { paths, to } => {
|
||||
let msg_tx = msg_tx.clone();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue