Are the rules for clearing Thunar's thumbnail cache set somewhere that the user can change?

I have recently discovered that my ~/.cache/thumbnails/normal/ folder contains some very old thumbnails. I was under the impression that these were automatically deleted with reasonable frequency. The contents of this folder suggests that I am wrong. I had a similar issue in Ubuntu 18.04 with GNOME and was under the impression that this was a Nautilus issue. However, having this same issue on Xubuntu 20.04 with Thunar suggests that I need to look elsewhere.

Are the deletion rules for the files in ~/.cache/thumbnails/ somewhere that I can easily access and change? Furthermore, is this an Ubuntu issue or have I simply had the misfortune of using two DEs with an identical issue?


Solution 1:

It would appear that the only rule is that if you delete an image file from within thunar, the associated thumbnail file is also removed. However, if you delete it from the command-line or another file manager, it is not deleted and will just stay there.

It might be a good idea to prune automatically from the cache old thumbnail files. Even if you remove valid thumbnail files, they will be created anew when needed.

The tool to use is cron. For example, create a new file in the /etc/cron.d folder with the following contents:

0 21 * * * root find /home/*/.thumbnails/ -type f -atime +6 -exec rm '{}' \;

This cron-job will run as root at 9PM (21h), find all the thumbnail files in all home-folders and delete the ones that have not been accessed during the last 7 days (today +6 days).

If you rather wish to disable thumbnails, go to the menu Edit > Preferences > Display and set "Show Thumbnails" to Never.

For strong measures, you could also do:

cd ~/.cache
mv thumbnails xthumbnails
ln -s thumbnails /dev/null