From fa5f0c1fcdc3de454571deac3584b570bb394e1b Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Wed, 17 Jun 2015 14:49:55 +0200 Subject: [PATCH] Re-create thumbs/transcodes if deleted. Previously thumbs/transcodes were only created if mtime() of the file didn't match what was stored in the json-file. If you deleted a thumb/transcode from the cache_path, it would not be re-created unless you modify the mtime() of the original files (in album_path). --- scanner/TreeWalker.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scanner/TreeWalker.py b/scanner/TreeWalker.py index b4a4393..51bc2ff 100644 --- a/scanner/TreeWalker.py +++ b/scanner/TreeWalker.py @@ -68,9 +68,25 @@ class TreeWalker: if cached_album: cached_photo = cached_album.photo_from_path(entry) if cached_photo and file_mtime(entry) <= cached_photo.attributes["dateTimeFile"]: - message("cache hit", os.path.basename(entry)) - cache_hit = True - photo = cached_photo + cache_file = None + if "mediaType" in cached_photo.attributes: + if cached_photo.attributes["mediaType"] == "video": + # if video + cache_file = os.path.join(self.cache_path, video_cache(entry)) + else: + # if image + cache_file = os.path.join(self.cache_path, image_cache(entry, 1024, False)) + else: + # if image + cache_file = os.path.join(self.cache_path, image_cache(entry, 1024, False)) + + # at this point we have full path to cache image/video + # check if it actually exists + if os.path.exists(cache_file): + message("cache hit", os.path.basename(entry)) + cache_hit = True + photo = cached_photo + if not cache_hit: message("metainfo", os.path.basename(entry)) photo = Photo(entry, self.cache_path)