From 08bb17a7ebbccf1c113ed5935ca3d26ff81317e7 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 28 Mar 2025 14:14:29 -0600 Subject: [PATCH] Allow Trash to fallback to Delete on failure (#27682) This fixes trashing files from the git panel on SSH remotes that don't run a Desktop environment. Release Notes: - Fix trash to work on remotes with no desktop environment configured --- crates/fs/src/fs.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 75368978d7..c410e37d45 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; + } } }