Get TrashItems when deleting

This commit is contained in:
Jeremy Soller 2024-07-11 16:20:59 -06:00
parent f4975391ac
commit eba72e131a
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
3 changed files with 5 additions and 5 deletions

3
Cargo.lock generated
View file

@ -5975,8 +5975,7 @@ dependencies = [
[[package]] [[package]]
name = "trash" name = "trash"
version = "5.0.0" version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/jackpot51/trash-rs.git?branch=delete-info#e9fd256298bf9873a794dfe60a2261d1ed41674c"
checksum = "8d8fbfb70b1fad5c0b788f9b2e1bf4d04e5ac6efa828f1ed9ee462c50ff9cf05"
dependencies = [ dependencies = [
"chrono", "chrono",
"libc", "libc",

View file

@ -33,7 +33,7 @@ regex = "1"
serde = { version = "1", features = ["serde_derive"] } serde = { version = "1", features = ["serde_derive"] }
shlex = { version = "1.3" } shlex = { version = "1.3" }
tokio = { version = "1", features = ["sync"] } tokio = { version = "1", features = ["sync"] }
trash = "5.0" trash = { git = "https://github.com/jackpot51/trash-rs.git", branch = "delete-info" }
xdg = { version = "2.5.2", optional = true } xdg = { version = "2.5.2", optional = true }
xdg-mime = "0.3" xdg-mime = "0.3"
url = "2.5" url = "2.5"

View file

@ -307,7 +307,7 @@ impl Operation {
pub fn toast(&self) -> Option<String> { pub fn toast(&self) -> Option<String> {
match self { match self {
Self::Delete { paths } => Some(self.completed_text()), Self::Delete { .. } => Some(self.completed_text()),
//TODO: more toasts //TODO: more toasts
_ => None, _ => None,
} }
@ -432,10 +432,11 @@ impl Operation {
let total = paths.len(); let total = paths.len();
let mut count = 0; let mut count = 0;
for path in paths { for path in paths {
tokio::task::spawn_blocking(|| trash::delete(path)) let items_opt = tokio::task::spawn_blocking(|| trash::delete(path))
.await .await
.map_err(err_str)? .map_err(err_str)?
.map_err(err_str)?; .map_err(err_str)?;
//TODO: items_opt allows for easy restore
count += 1; count += 1;
let _ = msg_tx let _ = msg_tx
.lock() .lock()