cache file hash

This commit is contained in:
j 2014-05-26 11:27:20 +02:00
parent 60a454d929
commit bc9e6cc92d
1 changed files with 2 additions and 2 deletions

View File

@ -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():