[PhotoFloat] [PATCH] Obsess over processing errors

Jerome Charaoui jerome at riseup.net
Mon Jan 27 17:16:06 CET 2014


When PhotoFloat encounters a processing error (corrupt jpeg, for
example), it reports it the first time around on the console and the
expected image will be absent from the gallery. When running the scanner
anew on the same (unmodified) tree, the same album will be considered as
a "full cache" and no further processing will occur. However the corrupt
image(s) will still be missing from the gallery. Unless the user has
explicitly recorded the output from the first processing run, PhotoFloat
will not report the error again unless the user forcibly deletes json
data from the cache.

With this patch, albums which produce errors during processing will not
be considered "full cache", so that upon relaunching the scanner on the
same tree, PhotoFloat will again attempt to process the images and
report the error, greatly facilitating the task of pinpointing
problematic images in large collections.

---
diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py
index d89733c..e74114e 100644
--- a/scanner/PhotoAlbum.py
+++ b/scanner/PhotoAlbum.py
@@ -16,6 +16,7 @@ class Album(object):
 		self._albums = list()
 		self._photos_sorted = True
 		self._albums_sorted = True
+		self._full_cache = True
 	@property
 	def photos(self):
 		return self._photos
@@ -25,6 +26,12 @@ class Album(object):
 	@property
 	def path(self):
 		return self._path
+	@property
+	def full_cache(self):
+		return self._full_cache
+	@full_cache.setter
+	def full_cache(self, value):
+		self._full_cache = value
 	def __str__(self):
 		return self.path
 	@property
@@ -85,6 +92,7 @@ class Album(object):
 		if not cripple:
 			for subalbum in dictionary["albums"]:
 				album.add_album(Album.from_dict(subalbum), cripple)
+		album.full_cache = dictionary["fullCache"]
 		album._sort()
 		return album
 	def to_dict(self, cripple=True):
@@ -93,12 +101,12 @@ class Album(object):
 		if cripple:
 			for sub in self._albums:
 				if not sub.empty:
-					subalbums.append({ "path": trim_base_custom(sub.path, self._path),
"date": sub.date })
+					subalbums.append({ "path": trim_base_custom(sub.path, self._path),
"date": sub.date, "fullCache": self.full_cache })
 		else:
 			for sub in self._albums:
 				if not sub.empty:
 					subalbums.append(sub)
-		return { "path": self.path, "date": self.date, "albums": subalbums,
"photos": self._photos }
+		return { "path": self.path, "date": self.date, "fullCache":
self.full_cache, "albums": subalbums, "photos": self._photos }
 	def photo_from_path(self, path):
 		for photo in self._photos:
 			if trim_base(path) == photo._path:
@@ -367,6 +375,8 @@ class Photo(object):
 		os.unlink(tfn)

 	def _video_transcode(self, transcode_path, original_path):
+		if not self.is_valid:
+			return
 		transcode_path = os.path.join(transcode_path, cache_base(self._path)
+ '.webm')
 		transcode_cmd = ['/usr/bin/ffmpeg', '-i', original_path, '-c:v',
'libvpx', '-crf', '10', '-b:v', '800k', '-c:a', 'libvorbis', '-f',
'webm', '-threads', '2', '-loglevel', '0', '-y']
 		filters = []
diff --git a/scanner/TreeWalker.py b/scanner/TreeWalker.py
index c2dbd53..5790a85 100644
--- a/scanner/TreeWalker.py
+++ b/scanner/TreeWalker.py
@@ -8,6 +8,7 @@ import json

 class TreeWalker:
 	def __init__(self, album_path, cache_path):
+		self.invalid = []
 		self.album_path =
os.path.abspath(album_path).decode(sys.getfilesystemencoding())
 		self.cache_path =
os.path.abspath(cache_path).decode(sys.getfilesystemencoding())
 		set_cache_path_base(self.album_path)
@@ -16,7 +17,11 @@ class TreeWalker:
 		self.walk(self.album_path)
 		self.big_lists()
 		self.remove_stale()
-		message("complete", "")
+		if len(self.invalid):
+			for i in self.invalid:
+				message("processing failed", i)
+		else:
+			message("complete", "")
 	def walk(self, path):
 		next_level()
 		message("walking", os.path.basename(path))
@@ -26,7 +31,7 @@ class TreeWalker:
 		if os.path.exists(cache):
 			try:
 				cached_album = Album.from_cache(cache)
-				if file_mtime(path) <= file_mtime(cache):
+				if file_mtime(path) <= file_mtime(cache) and cached_album.full_cache:
 					message("full cache", os.path.basename(path))
 					cached = True
 					album = cached_album
@@ -69,6 +74,8 @@ class TreeWalker:
 					self.all_photos.append(photo)
 					album.add_photo(photo)
 				else:
+					self.invalid.append(entry)
+					album.full_cache = False
 					message("unreadable", os.path.basename(entry))
 				back_level()
 		if not album.empty:


More information about the PhotoFloat mailing list