diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index c000f97..e59b987 100644
a
|
b
|
class CachedFilesMixin(object):
|
65 | 65 | compiled = re.compile(pattern) |
66 | 66 | self._patterns.setdefault(extension, []).append(compiled) |
67 | 67 | |
| 68 | def get_file_hash(self, name, content=None): |
| 69 | """Gets the MD5 hash of the file.""" |
| 70 | md5 = hashlib.md5() |
| 71 | for chunk in content.chunks(): |
| 72 | md5.update(chunk) |
| 73 | return md5.hexdigest()[:12] |
| 74 | |
68 | 75 | def hashed_name(self, name, content=None): |
69 | 76 | parsed_name = urlsplit(unquote(name)) |
70 | 77 | clean_name = parsed_name.path.strip() |
… |
… |
class CachedFilesMixin(object):
|
79 | 86 | return name |
80 | 87 | path, filename = os.path.split(clean_name) |
81 | 88 | root, ext = os.path.splitext(filename) |
82 | | # Get the MD5 hash of the file |
83 | | md5 = hashlib.md5() |
84 | | for chunk in content.chunks(): |
85 | | md5.update(chunk) |
86 | | md5sum = md5.hexdigest()[:12] |
| 89 | file_hash = self.get_file_hash(clean_name, content) |
87 | 90 | hashed_name = os.path.join(path, u"%s.%s%s" % |
88 | | (root, md5sum, ext)) |
| 91 | (root, file_hash, ext)) |