Fix permanent deletions not being warned when unable to trash files, refactor trash and unlinking code
Changes the warn
argument on thunar_application_unlink_files
to a bitwise flag warn_mode
. This allows the caller to only warn the user for a specific type of deletion.
Prior to e6e43a3b, the warn argument, when true, only prompted the user for confirmation of permanent deletions. Callers of the function which set permanently
to false typically enabled warn
too. After e6e43a3b, warn
would also prompt the user before moving files to trash to accommodate for the new misc-confirm-move-to-trash
preference, the value of which would be passed warn
by most callers that set permanently
to false. The problem is even when the function is called with permanently
being false, the procedure will set it to true when any file in the file list cannot be trashed, and since warn
is false (by default in most cases via misc-confirm-move-to-trash
) this will result in all files in the file list being hard deleted.
This oversight can lead to the user accidentally hard deleting their home directory in a couple ways. 1. By dragging their home directory into the trash icon on their desktop (#1621 (closed)), or 2. by selecting their home directory in Thunar and pressing the delete key.
This branch can possibly be simplified. Instead of using a bitwise flag, the warn
argument can be defined to only apply to trash operations if permanent deletions are assumed to always need a warning/confirmation. It seems all callers always need to warn permanent deletes in the current state, but the option to not do so existed prior to e6e43a3b, when warn
applied only to them, so I did not want to unilaterally remove that ability.