7. Detect Modifications

One important thing is to assure that the thumbnail image displays the same information than the original, only in a downscaled version. To make this possible we use the modification time stored in the required 'Thumb::MTime' key and check if it's equal the current modification time of the original. If not we must recreate the thumbnail.

Example 2. Algorithm to check for modification.

if (file.mtime != thumb.MTime) {
      recreate_thumbnail ();
}
         

Note

It is not sufficient to do a file.mtime > thumb.MTime check. If the user moves another file over the original, where the mtime changes but is in fact lower than the thumbnail stored mtime, we won't recognize this modification.

If for some reason the thumbnail doesn't have the 'Thumb::MTime' key (although it's required) it should be recreated in any case.

Note

There are certain circumstances where a program can't or don't want to update a thumbnail (eg. within a history view of your recently edited files). This is legally but it should be indicated to the user that an thumbnail is maybe outdated or not even checked for modifications.