Add Rename

This commit is contained in:
Jeremy Soller 2024-02-28 15:07:50 -07:00
parent 8fed9dd216
commit 1dc9b9c1b1
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
4 changed files with 145 additions and 1 deletions

View file

@ -29,6 +29,10 @@ pub enum Operation {
NewFolder {
path: PathBuf,
},
Rename {
from: PathBuf,
to: PathBuf,
},
/// Restore a path from the trash
Restore {
paths: Vec<trash::TrashItem>,
@ -74,6 +78,13 @@ impl Operation {
.map_err(err_str)?;
let _ = msg_tx.send(Message::PendingProgress(id, 100.0)).await;
}
Self::Rename { from, to } => {
tokio::task::spawn_blocking(|| fs::rename(from, to))
.await
.map_err(err_str)?
.map_err(err_str)?;
let _ = msg_tx.send(Message::PendingProgress(id, 100.0)).await;
}
Self::Restore { paths } => {
let total = paths.len();
let mut count = 0;