17

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.

Eric Carvalho
  • 54,385
  • If you have some free time you could take a look at libnautilus-private/nautilus-file-operations.c in the source (apt-get source nautilus). I don't have the diligence and patience for reading C. Interesting question though. +1 – phipsalabim Mar 09 '13 at 00:44
  • 3
    rm -rf ~/.local/share/Trash might be faster. See http://askubuntu.com/a/468722/2273 – Adam Monsen Nov 10 '15 at 19:52

1 Answers1

5

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

Meer Borg
  • 4,963
  • when I access nautilus trash, it freezes nautilus for a long time that I cant press anything; I wonder if there could have some way to disable it or popup if I really want to see it on nautilus because I use it for many other things and then, suddenly I have to wait like 3 minutes to be able to use nautilus again if I dont want to restart it :( – Aquarius Power Sep 29 '14 at 20:43