1
e11sync/app/lib/staticfiles.py

17 lines
522 B
Python
Raw Normal View History

2024-01-27 19:19:51 +02:00
from hashlib import sha256
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
class ManifestStaticFilesStorageSha256(ManifestStaticFilesStorage):
def file_hash(self, name, content=None):
"""
Return a hash of the file with the given name and optional content.
"""
if content is None:
return None
hasher = sha256(usedforsecurity=False)
for chunk in content.chunks():
hasher.update(chunk)
return hasher.hexdigest()