Use spinal.hash_file instead of redefining here.

This commit is contained in:
voussoir 2021-01-25 14:59:40 -08:00
parent b5e8363374
commit 38e9b796fe
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 4 additions and 10 deletions

View file

@ -278,15 +278,6 @@ def get_mimetype(filepath):
mimetype = mimetypes.guess_type(filepath)[0] mimetype = mimetypes.guess_type(filepath)[0]
return mimetype return mimetype
def hash_file(filepath, hasher):
bytestream = read_filebytes(filepath)
for chunk in bytestream:
hasher.update(chunk)
return hasher.hexdigest()
def hash_file_md5(filepath):
return hash_file(filepath, hasher=hashlib.md5())
def hash_photoset(photos): def hash_photoset(photos):
''' '''
Given some photos, return a fingerprint string for that particular set. Given some photos, return a fingerprint string for that particular set.

View file

@ -1,4 +1,7 @@
import hashlib
from voussoirkit import cacheclass from voussoirkit import cacheclass
from voussoirkit import spinal
import etiquette import etiquette
@ -98,7 +101,7 @@ class FileEtag:
if do_refresh: if do_refresh:
self._stored_hash_time = mtime self._stored_hash_time = mtime
self._stored_hash_value = etiquette.helpers.hash_file_md5(self.filepath) self._stored_hash_value = spinal.hash_file(self.filepath, hash_class=hashlib.md5)
return self._stored_hash_value return self._stored_hash_value