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
This commit is contained in:
Conrad Irwin 2025-03-28 14:14:29 -06:00 committed by GitHub
parent 55c1f9d26c
commit 08bb17a7eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}
}
}