Do additional/smarter file change checks for timeline thumbnail tiles or waveforms caches
Submitted by Jeff F.T.
Assigned to Jeff F.T.
<zeph> normalized audio to make waveforms more prominent in some clips,
but difference not showing up. seems cache needs updating.
<Mathieu_Du> rm -r ~/.cache/pitivi/waves/
<nekohayo> afaik the thumbnailer that Daniel Thul wrote initially was computing a hash from the first few pieces of data from the file, to determine if it had changed
<Mathieu_Du> Hm yeah that's what I remember as well
<nekohayo> though we could also be more naive and look at
the file mtime + filesize
<Mathieu_Du> might be better than just looking at the beginning of the file
After having a quick look at timeline/previewers.py and then utils/misc.py, we indeed call the hash_file function to do a sha256 of the beginning of the file, which is used to determine the name of the thumbnail/waveform cache file. So in a sense it protects against big variations and it protects us from the mess of dealing with the file paths (which can change at anytime behind our backs outside of pitivi, which would mean a lot of wasted effort regenerating stuff that we already had in cache), but I suspect it can be fooled by changes that occur further in the media file (not at the beginning).
So after we get a hash that matches an existing cache file, maybe we could additionally do something like this:
if filesize changed:
throw away the cache, log a warning/info about that
recreate it from scratch
We can probably rely on filesize (I can't imagine modifying a media file and ending up with the exact same filesize down to the last octet), but we can't rely on the modification timestamp (file managers or other things might have touched it while moving the file around etc.)
The problem is where to store that filesize information...
Imported from https://bugzilla.gnome.org/show_bug.cgi?id=722747