Little bugs and status output.
This commit is contained in:
parent
7ce3c03225
commit
ff5aac5bad
@ -140,6 +140,7 @@ class Photo(object):
|
||||
else:
|
||||
suffix = str(size)
|
||||
thumb_path = os.path.join(thumb_path, image_cache(self._path, suffix))
|
||||
print "Thumbing %s" % thumb_path
|
||||
if os.path.exists(thumb_path) and datetime.fromtimestamp(os.path.getmtime(thumb_path)) >= self._attributes["DateTimeFile"]:
|
||||
return
|
||||
image = image.copy()
|
||||
@ -159,7 +160,10 @@ class Photo(object):
|
||||
image.save(thumb_path, "JPEG")
|
||||
|
||||
def _thumbnails(self, image, thumb_path):
|
||||
orientation = self._attributes["Orientation"]
|
||||
if "Orientation" in self._attributes:
|
||||
orientation = self._attributes["Orientation"]
|
||||
else:
|
||||
orientation = 1
|
||||
mirror = image
|
||||
if orientation == 2:
|
||||
# Vertical Mirror
|
||||
@ -214,7 +218,7 @@ class Photo(object):
|
||||
dictionary[key] = datetime.strptime(dictionary[key], "%a %b %d %H:%M:%S %Y")
|
||||
except:
|
||||
pass
|
||||
return Photo(path, dictionary)
|
||||
return Photo(path, None, dictionary)
|
||||
def to_dict(self):
|
||||
photo = { "name": self.name, "date": self.date }
|
||||
photo.update(self.attributes)
|
||||
|
@ -13,12 +13,15 @@ class TreeWalker:
|
||||
self.walk(album_path)
|
||||
self.remove_stale()
|
||||
def walk(self, path):
|
||||
print "Walking %s" % path
|
||||
cache = os.path.join(self.cache_path, json_cache(path))
|
||||
cached = False
|
||||
cached_album = None
|
||||
if os.path.exists(cache):
|
||||
print "Has cache %s" % path
|
||||
cached_album = Album.from_cache(cache)
|
||||
if os.path.getmtime(path) <= os.path.getmtime(cache):
|
||||
print "Album is fully cached"
|
||||
cached = True
|
||||
album = cached_album
|
||||
if not cached:
|
||||
@ -32,13 +35,16 @@ class TreeWalker:
|
||||
if cached_album:
|
||||
cached_photo = cached_album.photo_from_path(entry)
|
||||
if cached_photo and datetime.fromtimestamp(os.path.getmtime(entry)) <= cached_photo.attributes["DateTimeFile"]:
|
||||
print "Photo cache hit %s" % entry
|
||||
cache_hit = True
|
||||
photo = cached_photo
|
||||
if not cache_hit:
|
||||
print "No cache - scanning %s" % entry
|
||||
photo = Photo(entry, self.cache_path)
|
||||
if photo.is_valid:
|
||||
self.all_photos.append(photo)
|
||||
album.add_photo(photo)
|
||||
print "Writing cache of %s" % album.cache_path
|
||||
album.cache(self.cache_path)
|
||||
self.all_albums.append(album)
|
||||
return album
|
||||
|
Loading…
Reference in New Issue
Block a user