Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Allow Trash to fallback to Delete on failure (#27682)

Conrad Irwin08bb17a7ebbc
diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs
index 75368978d74..c410e37d453 100644
--- a/crates/fs/src/fs.rs
+++ b/crates/fs/src/fs.rs
@@ -453,7 +453,12 @@ impl Fs for RealFs {
let file = smol::fs::File::open(path).await?;
match trash::trash_file(&file.as_fd()).await {
Ok(_) => Ok(()),
- Err(err) => Err(anyhow::Error::new(err)),
+ Err(err) => {
+ log::error!("Failed to trash file: {}", err);
+ // Trashing files can fail if you don't have a trashing dbus service configured.
+ // In that case, delete the file directly instead.
+ return self.remove_file(path, RemoveOptions::default()).await;
+ }
}
}