From bc9e6cc92de57138d3405c8e127a4dd1d5340d39 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 26 May 2014 11:27:20 +0200 Subject: [PATCH] cache file hash --- oml/media/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oml/media/__init__.py b/oml/media/__init__.py index 3cc0b8f..8b0a7b3 100644 --- a/oml/media/__init__.py +++ b/oml/media/__init__.py @@ -16,7 +16,7 @@ def get_id(f=None, data=None): if data: return base64.b32encode(hashlib.sha1(data).digest()) else: - return base64.b32encode(ox.sha1sum(f).decode('hex')) + return base64.b32encode(ox.sha1sum(f, cached=True).decode('hex')) def metadata(f): @@ -56,7 +56,7 @@ def metadata(f): data['title'] = os.path.splitext(os.path.basename(f))[0] if data['title'].startswith('Microsoft Word - '): data['title'] = data['title'][len('Microsoft Word - '):] - for postfix in ('.doc', 'docx', '.qxd', '.indd'): + for postfix in ('.doc', 'docx', '.qxd', '.indd', '.tex'): if data['title'].endswith(postfix): data['title'] = data['title'][:-len(postfix)] if not data['title'].strip():