If thumbing or transcoding fails, invalidate entry.

patches
Jerome Charaoui 2013-12-21 20:46:56 -05:00
parent aa55758aab
commit 0443b99492
1 changed files with 6 additions and 0 deletions

View File

@ -242,6 +242,7 @@ class Photo(object):
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except:
self.is_valid = False
return return
info = json.loads(p) info = json.loads(p)
for s in info["streams"]: for s in info["streams"]:
@ -279,6 +280,7 @@ class Photo(object):
raise raise
except: except:
message("corrupt image", os.path.basename(original_path)) message("corrupt image", os.path.basename(original_path))
self.is_valid = False
return return
if square: if square:
if image.size[0] > image.size[1]: if image.size[0] > image.size[1]:
@ -302,6 +304,7 @@ class Photo(object):
except: except:
message("save failure", os.path.basename(thumb_path)) message("save failure", os.path.basename(thumb_path))
os.unlink(thumb_path) os.unlink(thumb_path)
self.is_valid = False
def _photo_thumbnails(self, image, thumb_path, original_path): def _photo_thumbnails(self, image, thumb_path, original_path):
mirror = image mirror = image
@ -339,6 +342,7 @@ class Photo(object):
except: except:
message("couldn't extract video frame", os.path.basename(original_path)) message("couldn't extract video frame", os.path.basename(original_path))
os.unlink(tfn) os.unlink(tfn)
self.is_valid = False
return return
try: try:
image = Image.open(tfn) image = Image.open(tfn)
@ -347,6 +351,7 @@ class Photo(object):
except: except:
message("couldn't open video thumbnail", tfn) message("couldn't open video thumbnail", tfn)
os.unlink(tfn) os.unlink(tfn)
self.is_valid = False
return return
mirror = image mirror = image
if "rotate" in self._attributes: if "rotate" in self._attributes:
@ -392,6 +397,7 @@ class Photo(object):
os.unlink(transcode_path) os.unlink(transcode_path)
except: except:
pass pass
self.is_valid = False
return return
self._video_metadata(transcode_path, False) self._video_metadata(transcode_path, False)