cache file hash
This commit is contained in:
parent
60a454d929
commit
bc9e6cc92d
1 changed files with 2 additions and 2 deletions
|
@ -16,7 +16,7 @@ def get_id(f=None, data=None):
|
||||||
if data:
|
if data:
|
||||||
return base64.b32encode(hashlib.sha1(data).digest())
|
return base64.b32encode(hashlib.sha1(data).digest())
|
||||||
else:
|
else:
|
||||||
return base64.b32encode(ox.sha1sum(f).decode('hex'))
|
return base64.b32encode(ox.sha1sum(f, cached=True).decode('hex'))
|
||||||
|
|
||||||
|
|
||||||
def metadata(f):
|
def metadata(f):
|
||||||
|
@ -56,7 +56,7 @@ def metadata(f):
|
||||||
data['title'] = os.path.splitext(os.path.basename(f))[0]
|
data['title'] = os.path.splitext(os.path.basename(f))[0]
|
||||||
if data['title'].startswith('Microsoft Word - '):
|
if data['title'].startswith('Microsoft Word - '):
|
||||||
data['title'] = data['title'][len('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):
|
if data['title'].endswith(postfix):
|
||||||
data['title'] = data['title'][:-len(postfix)]
|
data['title'] = data['title'][:-len(postfix)]
|
||||||
if not data['title'].strip():
|
if not data['title'].strip():
|
||||||
|
|
Loading…
Reference in a new issue