Great Index: Using MD5 checksums instead file paths.

Performance impact is negligible, it simplify the code and is much more error resistant.
This commit is contained in:
Paweł Jastrzębski
2014-01-24 22:43:24 +01:00
parent bd53c6108d
commit 3bb8cc7778
2 changed files with 26 additions and 12 deletions
+13 -1
View File
@@ -21,10 +21,22 @@ __copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jas
__docformat__ = 'restructuredtext en'
import os
from hashlib import md5
from functools import reduce
from PIL import Image, ImageOps, ImageStat, ImageChops
def md5Checksum(filePath):
with open(filePath, 'rb') as fh:
m = md5()
while True:
data = fh.read(8192)
if not data:
break
m.update(data)
return m.hexdigest()
class ProfileData:
def __init__(self):
pass
@@ -146,7 +158,7 @@ class ComicPage:
else:
filename += ".jpg"
self.image.save(filename, "JPEG", optimize=1)
return [filename, flags]
return [md5Checksum(filename), flags]
else:
return None
except IOError as e: