MCPcopy
hub / github.com/django/django / file_hash

Method file_hash

django/contrib/staticfiles/storage.py:131–140  ·  view source on GitHub ↗

Return a hash of the file with the given name and optional content.

(self, name, content=None)

Source from the content-addressed store, hash-verified

129 self._patterns.setdefault(extension, []).append((compiled, template))
130
131 def file_hash(self, name, content=None):
132 """
133 Return a hash of the file with the given name and optional content.
134 """
135 if content is None:
136 return None
137 hasher = md5(usedforsecurity=False)
138 for chunk in content.chunks():
139 hasher.update(chunk)
140 return hasher.hexdigest()[:12]
141
142 def hashed_name(self, name, content=None, filename=None):
143 # `filename` is the name of file to hash if `content` isn't given.

Callers 2

hashed_nameMethod · 0.95
save_manifestMethod · 0.45

Calls 2

chunksMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected