Undo unrecoverably deletes files created by other programs in a directory created by Thunar
Today I discovered the recently added to Thunar Undo/Redo feature in an unpleasant way:
- created a directory in Thunar;
- let an external program create files in this directory;
- pressed Ctrl+Z while Thunar had focus thinking that another application has focus;
- noticed the desktop notification and realized that all files created by the external program are unrecoverably lost.
Undoing the Create-Folder action should behave as rmdir
not as rm -r
. That is, the undoing should fail if there is at least one file in the directory.
A similar issue exists with undoing file creation:
- create a file;
- write some text and save the file;
- Undo in Thunar;
- Redo in Thunar.
Actual result: the file is empty and the Redo action is disabled.
Expected result: Thunar refuses to delete the file if its contents differs from what was originally created (the original contents can be nonempty if the file is created from a template).
Other critical bugs can exist in the Undo/Redo feature. I recommend to consider carefully what else might go wrong and fix it rather than wait for another data-loss bug report.
Workaround: remove shortcuts for Undo and Redo actions in Thunar's Preferences => Shortcuts tab. I'll keep this workaround even after the bugs are fixed, because other bugs are possible (now or in the future). Furthermore, accidental filesystem changes can go unnoticed until another operation is performed in Thunar or Thunar exits. And then these filesystem changes can no longer be reverted (redone).
I advise removing these default shortcuts from Thunar code. The tiny minority of users, who use this feature so often that the main menu is cumbersome, can assign shortcuts manually. At the very least the default shortcuts should be removed until these bugs are fixed.