andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

`trash` goes into an infinite loop when trashing files with a long filename #166

Closed jonaskoelker closed 3 years ago

jonaskoelker commented 4 years ago

At https://github.com/andreafrancia/trash-cli/blob/master/trashcli/put.py#L428 there's a while True: loop, which tries to create a file whose name is the trashed file's name plus a suffix.

If the trashed file's name has a length that is permitted by the file system, but any longer filename is not permitted, this loop will keep trying various suffixes forever, always being denied.

Some better behavior IMO is to shrink the base name such that there's enough room for the suffix (I think, I don't know the details of the trashing standard), or aborting with an error, or skipping that one file and reporting it to the user.