Volumes that do not use trash (such as tmpfs) nevertheless show "Move to Trash" in the right-click menu in the main view. If the item is selected, Thunar opens a dialog box asking for confirmation and informing the user that this will permanently delete the selected files. An user who out of habit quickly confirms such dialogs might not notice this warning and accidently delete data he thought was going to the trash instead. Interestingly, the sidebar is correct, it only shows a "Delete" item on such volumes.
Created attachment 8505 proposed patch
Created attachment 8507 proposed patch v2 The first patch disables the entry for directories and files in ~/ also, because the parent directory /home/<user> cannot be trashed. Maybe this could be tweaked. The second patch uses another approach: check if selected file(s) can be trashed.
I am currently trying to reproduce the bug .. but while doing so, I get a different bug :F And it seems not to matter if I apply the "proposed patch v2" (Whereas the patch actually looks good to me) I open thunar in /run/user/1000, which, according to "mount | column -t" is a tmpfs which allows user to write. Now I create some file, e.g. "test". I get "move to trash" in the context menu. However on click, I dont get any confirmation dialog. The file is just deleted. The trash is empty. "Delete" is only shown, if enable it in the settings. (However on "delete" I get a confirmation dialog) Maybe the difference is related in me, using the current thunar master ? ... iirc we changed something related lately. Possibly there is a problem with "thunar_file_can_be_trashed" for volumes without trash ... to be further debugged.
I tested my patch again, and it worked for the scenario which you have described. A follow up patch is likely needed for both standard and tree view to show the "Delete" entry instead in case it is hidden.
FInally I found some time to look into it. Found out that the patch works well on my laptop (debian testing) but does not work on my desktop (debian stable). On my desktop, thunar_file_can_be_trashed returns TRUE for files on the tmpfs, which is clearly wrong. Looks like some bug in G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, which was fixed meanwhile. Patch looks good to me.
Theo Linkspfeifer referenced this bugreport in commit 809fd754c36d41f7556aecc576988a7c9dd3f067 Deactivate "Move to Trash" menu entry on volumes without trash (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=809fd754c36d41f7556aecc576988a7c9dd3f067
Theo Linkspfeifer referenced this bugreport in commit efcbf4d59a8bdd4d8197c92b857eead676ce2100 Deactivate "Move to Trash" menu entry on volumes without trash (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=efcbf4d59a8bdd4d8197c92b857eead676ce2100
pushed to master and 4.14 branch. Thanks for the fix !
Created attachment 8603 quick hack for standard view This diff adds the following logic when the "Delete" entry is disabled via setting: - show "Delete" entry instead if file cannot be trashed, but can be deleted - show non-sensitive "Move to Trash" entry if file cannot be trashed/deleted What do you think about this idea?
Meh ... bad timing :P I agree that it makes sense to show "delete" if it is the only option. For the second one, I already see a nonsensitive "Move to Trash" on files in / .... so seems to be already in place. Do I miss something ?
The change from point one would result in seeing non-sensitive "Delete" on files without write access. Point two corrects that, but this is basically just cosmetical and it makes the condition more complex.
Tried Thunar 1.8.7 with this change and I cannot delete files via WebDAV -- Shift + Delete does nothing and there is no "Delete" option in the context menu. :\
Created attachment 8709 Follow-up fix to show "Delete" for untrashable files The attached patch seems to do what I'd expect, which is: In $HOME -- shows "Move to Trash" In /tmp -- shows "Delete" (and hides "Move to Trash") In / -- shows *grayed out* "Move to Trash" (The "misc-show-delete-action" option behaves as expected too.) What do you think?
Argh, another regression ... thanks for sorting it out, the patch looks good to me. I dont have a WebDAV around ... would need to setup some first. Though it seems to work well. Theo recently mentioned another regression: > looks like this commit disabled deleting files in Trash via DEL key Your patch seems to fix that regression as well :) @Theo What do you think ? Could you please give the patch a spin ?
Evangelos Foutras referenced this bugreport in commit 9ad27be6e40cec1372f9ec1eee9b3262fb4c18bb Replace Trash action with Delete as needed (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=9ad27be6e40cec1372f9ec1eee9b3262fb4c18bb
Evangelos Foutras referenced this bugreport in commit e0f50533edc8abcff0e478f423e290c786ce82ed Replace Trash action with Delete as needed (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=e0f50533edc8abcff0e478f423e290c786ce82ed
Agreed by Theo via irc, pushed to 4.14 and master. Thanks alot for the patch !
Created attachment 8717 Get rid of bitwise AND in logical expression Thanks for applying the patch. Could you please apply this one too? (I made a silly choice to use bitwise AND in a boolean expression; the attached patch fixes that.) Sorry for the extra work. 😞
Evangelos Foutras referenced this bugreport in commit e9754339aa6478e511a5302654107ad379bc6c9d Get rid of bitwise AND in logical expression (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=e9754339aa6478e511a5302654107ad379bc6c9d
Evangelos Foutras referenced this bugreport in commit dab96b3f68c6fb8dafd35a2ef6efa875bb955e6d Get rid of bitwise AND in logical expression (Bug #15352) https://git.xfce.org/xfce/thunar/commit?id=dab96b3f68c6fb8dafd35a2ef6efa875bb955e6d
Ok, done. Dont have a strong opinion on bitwise AND myself. For me both is fine :) But yes, I guess the boolean expression in the same line improves readability.