andreafrancia / trash-cli

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

`trash-put` hangs my system for a while #298

Closed qadzek closed 1 year ago

qadzek commented 1 year ago

Describe the bug Thank you for this very useful application. Using trash-put instead of rm saved me a couple of times!

I noticed that my system hangs for a while when I use trash-put. It gets worse for every extra file I want to remove. E.g. when I execute touch foo{1..20}.txt, followed by trash-put foo*.txt, my system hangs for more than 10 seconds (I can't change to another window, my clock freezes etc.). Removing e.g. 100 files takes a really long time.

The issue also happens when the files aren't empty. However, it doesn't happen when I first move these files to a subdirectory and then remove that entire subdirectory.

I used pip to install version 0.23.2.13.2 on Linux Mint, but the same issue is present when I use apt to install version 0.17.1.14.

I tried the same commands on another system running Ubuntu, but I couldn't replicate the issue there.

Do you have any ideas how I could fix this?

trash-cli version 0.23.2.13.2

Are you using the latest version of trash-cli? Yes

Have you tried if the bug is present in the latest version of trash-cli? Yes

Operating system: Linux Mint 21.1

To Reproduce $ touch foo{1..20}.txt $ trash-put foo*.txt

andreafrancia commented 1 year ago

Sorry I don't how exactly how to help you. I can suggest to you to use the -vv option to increase verbosity. Maybe you discover something that would explain the problem.

$ touch foo && trash-put -vv foo
trash-put: volume of file: /
trash-put: trying trash dir: /Users/andrea/.local/share/Trash from volume: /
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo.trashinfo failed.
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo_1.trashinfo failed.
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo_2.trashinfo failed.
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo_3.trashinfo failed.
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo_4.trashinfo failed.
trash-put: attempt for creating /Users/andrea/.local/share/Trash/info/foo_5.trashinfo failed.
trash-put: .trashinfo created as /Users/andrea/.local/share/Trash/info/foo_6.trashinfo.
trash-put: 'foo' trashed in ~/.local/share/Trash

Basically trash-put should not do any intensive operation. I does only two things:

The TRASH_DIR directory should be in the same volume of the file to be trashed. This mean that, usually, the move is immediate.

You may want check if you are using some weird filesystem (for example s3 bucket mounted as a disk), or you have in place some mechanism that will slow down the attempt of creating a file, or there too many files in $TRASH_DIR/files and $TRASH_DIR/info directories.

Keep me posted

qadzek commented 1 year ago

Thanks for your help.

Using the -vv option basically returned the same output as in your case.

When I execute touch foo{1..100}.txt && trash-put -vv foo*.txt, I see nothing for a number of seconds and then suddenly I receive all the verbose output very rapidly. I am not sure if I don't see any output at first because the systems hangs, or because something is preventing trash-put from starting its task.

Emptying the trash seems to have improved things (it was last emptied a pretty long time ago). I did empty both ~/.local/share/Trash/files and ~/.local/share/Trash/info. I can now remove about 100 (empty) files in 10 seconds, before it was only 20 files in 10 seconds, but the system still hangs for some time.

I don't think there is anything unusual about my setup. The filesystem is EXT4. I did enable full disk encryption though.

arthursw commented 1 year ago

Note: I had problems with trash-list, trash-empty and trash-restore, they would hang and do nothing because of a problem with my mounted volumes. I unmounted all my volumes, and trash-cli worked again.

qadzek commented 1 year ago

@andreafrancia I am closing this issue because I discovered that trash-cli isn't the cause of the problem.

I noticed that the same issue occurs when I use my GUI file manager (Nemo) and move a large number of files to trash. Just like the issue doesn't occur when I use rm on the command line, it doesn't occur when I permanently delete (Shift+Delete) in the GUI.

It's probably related to a very old bug in the Cinnamon desktop environment. I guess trash-cli experiences a bug in the desktop environment because it uses the DE to move files to trash.

andreafrancia commented 1 year ago

It's probably related to a very old bug in the Cinnamon desktop environment. I guess trash-cli experiences a bug in the desktop environment because it uses the DE to move files to trash.

Actually trash-cli does not use the Desktop Environment to move the file in the trashcan. It just uses some spec that are used also by many Dekstop Environment.

Probably both Nemo and trash-cli are facing the same problem. If you resolve the problem please send here the solution that it might help some other people. Even if it is not related directly to trash-cli, thank you.