Add empty trash, fixes #118

This commit is contained in:
Jeremy Soller 2024-05-09 13:24:06 -06:00
parent 99c378873a
commit 1116eaa05a
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
5 changed files with 91 additions and 15 deletions

View file

@ -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 || {