22 Nov 2006 gpoo   » (Master)

How much space are eating your thumbnails?

Thumbnails are created by applications and thanks to a proposed draft are shared among desktops. But, it doesnot mean that every thumbnail stored in your home directory is useful for the purpose they were created. Some of them points to a file that doesnot exists anymore, some of them are broken images, and some of them were created by applications that doesnot respect the proposed draft.

Basically there are two size of thumbnails: normal (128x128 pixels) and large (256x256 pixels). Each thumbnail must contains at least two pairs of key/value, one of them is the URI of the original file and the another one is the last time the file was modified.

To get the file name of a thumbnail a MD5 sum must be applied to its URI. If you move the file to a new location, then the name of the thumbnail must be updated (also its metadata).

When you delete a file through Nautilus, this file is moved to the Trash folder. Furthermore, its thumbnail must be updated. Nautilus does it right, which is good. But, when you expunge the Trash, only the original file is deleted, not the thumbnail; which is bad, but easy to fix.

On the other hand, when you rename a folder, the next time the folder will be visited (in this case under a new name), the thumbnails will be regenerated, because for each URI there is no a thumbnails associated. Now, you have two thumbnails stored for the same file, but only one is valid. If you repeat this step often, your .thumbnails filder will get polluted of useless thumbnails.

Instead of renaming the folder, you can create a new folder, then move the group of files there, and finally, delete the old one. In this case Nautilus will not regenerate the thumbnails, it will update the thumbnails correctly. At least in the first hiearchy (I have not test it deeply).

The worst case happens when the files are moved or deleted by a non free desktop compliant (or kind of compliant) application, let's say the shell. The thumbnails associated to those files will not be updated or deleted. (inotify to rescue?).

The average for a normal thumbnail is 25Kb of space while for a large one is 75Kb. If you maintain a lot of pictures in a long period of time (with all the file management involved), probably you have enough space wasted by useless thumbnails.

At least, I had. And I have the feeling that some other people, too. A time to live for thumbnails was requested, as is filed in bugzilla #150483.

Instead of delete my old thumbnails, I prefer to delete only the useless ones (in the sense of my first paragraph). So, I wrote a little script in Python (shorter than my comment) that estimate how much space I am wasting because of useless thumbnails.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!