I started noticing some time ago in Xfce4 that when I sent some file to the Trash, tumbler (the Xfce4 thumbnailer) would cause very high I/O load for quite some time. Upon investigating the issue, I found that it was scanning the ~/.thumbnails directory, which was very large in size.
So I decided to write a cron script that will periodically clean the ~/.thumbnails directory, but there is a certain directory of large video files that tumbler takes a bit of time, and sometimes even fails, to create thumbnails for.
The idea is removing all thumbnails, except the ones for these videos. But in order to keep these thumbnails, I have to find what their names are. The problem is that thumbnails are stored named with a md5sum of the URI, plus the PNG extension.
Upon looking at the tumbler source, I found the name for the thumbnail is generated in the following line:
md5_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
The documentation for g-compute-checksum-for-string says:
g_compute_checksum_for_string(GChecksumType checksum_type,
const gchar *str,
gssize length);
checksum_type: a GChecksumType
str: the string to compute the checksum of
length: the length of the string, or -1 if the string is null-terminated.
To put it short, the thumbnail for a file named /home/teresaejunior/File 01.png will be stored in the .thumbnails/ directory as a8502be3273541e618b840204479a7f9.png
According to the ThumbnailerSpec, URI is file://filename. I did some research on the "null character", and thought \0 would do the trick. In order to achieve the result a8502be3273541e618b840204479a7f9, I believed the following should work:
printf "file:///home/teresaejunior/File 01.png\0" | md5sum
but that returns f507285c45d293fa66bc0b813d17b6e6 instead.
Can someone give me some advice? I believe my printf line is flawed. What is my command doing different from g_compute_checksum_for_string?
>>> m = hashlib.md5('file:///home/teresaejunior/File 01.png\0')>>> m.hexdigest()'f507285c45d293fa66bc0b813d17b6e6'– Ignacio Vazquez-Abrams Sep 19 '13 at 1:44a8502be3273541e618b840204479a7f9, although it was generated by the function I mentioned. Please, click on the link for the tumbler source for details. – Teresa e Junior Sep 19 '13 at 1:47od:printf "file:///home/teresaejunior/File 01.png\0" | od -c. – terdon♦ Sep 19 '13 at 3:23