Why does emptying the rubbish bin in nautilus take so long?

For the purpose of this question, "large directory" means for example a Linux kernel git repository, or the Chromium source.

If I rm -rf a large directory like this from the shell, it is deleted in only a couple of seconds at most.

If I move it to trash first and then empty the trash, the first operation takes under a second, then the actual delete takes several minutes (we are talking double figures.)

Why is emptying the trash so slow? What is it doing when it says "preparing." How much preparation does it actually take to run rm -rf ~/.local/share/Trash/?

I've been looking at this for over 20 minutes now.


Solution 1:

When the first operation occurs it just moves the files to the trash.

When you "trash" those files it loads the entire tree file into memory and then deletes each file one by one. This allows for timing calculations to know how long it takes to delete the file, how many files are to be deleted, how big those files are, although most of the parameters are not used here, and allows you to press that little red cross to stop the process.

Thats why I always delete from the shell