diff --git a/etiquette/helpers.py b/etiquette/helpers.py index 4d75a4a..77490cf 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -278,15 +278,6 @@ def get_mimetype(filepath): mimetype = mimetypes.guess_type(filepath)[0] 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): ''' Given some photos, return a fingerprint string for that particular set. diff --git a/frontends/etiquette_flask/backend/client_caching.py b/frontends/etiquette_flask/backend/client_caching.py index 851c031..e7992f8 100644 --- a/frontends/etiquette_flask/backend/client_caching.py +++ b/frontends/etiquette_flask/backend/client_caching.py @@ -1,4 +1,7 @@ +import hashlib + from voussoirkit import cacheclass +from voussoirkit import spinal import etiquette @@ -98,7 +101,7 @@ class FileEtag: if do_refresh: 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