! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Thunar shows "Move to Trash" menu entry on volumes without trash
Status:
RESOLVED: FIXED

Comments

Description haarp 2019-05-02 16:23:33 CEST
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.
Comment 1 Theo Linkspfeifer editbugs 2019-05-10 00:00:09 CEST
Created attachment 8505 
proposed patch
Comment 2 Theo Linkspfeifer editbugs 2019-05-10 12:57:20 CEST
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.
Comment 3 alexxcons editbugs 2019-05-24 00:09:59 CEST
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.
Comment 4 Theo Linkspfeifer editbugs 2019-05-24 11:37:27 CEST
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.
Comment 5 alexxcons editbugs 2019-05-29 22:55:09 CEST
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.
Comment 6 Git Bot editbugs 2019-05-29 23:05:34 CEST
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
Comment 7 Git Bot editbugs 2019-05-29 23:08:30 CEST
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
Comment 8 alexxcons editbugs 2019-05-29 23:09:11 CEST
pushed to master and 4.14 branch. Thanks for the fix !
Comment 9 Theo Linkspfeifer editbugs 2019-05-30 11:05:41 CEST
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?
Comment 10 alexxcons editbugs 2019-05-30 21:58:29 CEST
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 ?
Comment 11 Theo Linkspfeifer editbugs 2019-05-30 22:40:30 CEST
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.
Comment 12 Evangelos Foutras 2019-06-29 00:56:41 CEST
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. :\
Comment 13 Evangelos Foutras 2019-06-30 13:21:55 CEST
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?
Comment 14 alexxcons editbugs 2019-06-30 22:39:09 CEST
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 ?
Comment 15 Git Bot editbugs 2019-07-01 23:13:35 CEST
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
Comment 16 Git Bot editbugs 2019-07-01 23:16:32 CEST
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
Comment 17 alexxcons editbugs 2019-07-01 23:17:47 CEST
Agreed by Theo via irc, pushed to 4.14 and master.

Thanks alot for the patch !
Comment 18 Evangelos Foutras 2019-07-02 00:48:55 CEST
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. 😞
Comment 19 Git Bot editbugs 2019-07-02 22:43:08 CEST
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
Comment 20 Git Bot editbugs 2019-07-02 22:46:56 CEST
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
Comment 21 alexxcons editbugs 2019-07-02 22:52:59 CEST
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.

Bug #15352

Reported by:
haarp
Reported on: 2019-05-02
Last modified on: 2019-07-02

People

Assignee:
Xfce Bug Triage
CC List:
3 users

Version

Attachments

proposed patch (2.22 KB, patch)
2019-05-10 00:00 CEST , Theo Linkspfeifer
no flags
proposed patch v2 (2.80 KB, patch)
2019-05-10 12:57 CEST , Theo Linkspfeifer
no flags
quick hack for standard view (1.54 KB, patch)
2019-05-30 11:05 CEST , Theo Linkspfeifer
no flags
Follow-up fix to show "Delete" for untrashable files (3.54 KB, patch)
2019-06-30 13:21 CEST , Evangelos Foutras
no flags
Get rid of bitwise AND in logical expression (1.66 KB, patch)
2019-07-02 00:48 CEST , Evangelos Foutras
no flags

Additional information