diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-02-27 21:30:07 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2016-03-30 14:34:41 +0200 |
| commit | edcecaf0dea718a8fb216df478df0d151a9ba04d (patch) | |
| tree | c01c92028af6141d4da58ec49ddd12441077d8a0 /django | |
| parent | 940b7fd5cbcd743658f741d37b3d7b1766ed1f17 (diff) | |
Fixed #19670 -- Applied CachedFilesMixin patterns to specific extensions
Thanks Simon Meers for the initial patch, and Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index 8949969c58..0909f51724 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -17,6 +17,7 @@ from django.core.files.base import ContentFile from django.core.files.storage import FileSystemStorage, get_storage_class from django.utils.encoding import force_bytes, force_text from django.utils.functional import LazyObject +from django.utils.six import iteritems from django.utils.six.moves.urllib.parse import ( unquote, urldefrag, urlsplit, urlunsplit, ) @@ -248,13 +249,14 @@ class HashedFilesMixin(object): # ..to apply each replacement pattern to the content if name in adjustable_paths: content = original_file.read().decode(settings.FILE_CHARSET) - for patterns in self._patterns.values(): - for pattern, template in patterns: - converter = self.url_converter(name, template) - try: - content = pattern.sub(converter, content) - except ValueError as exc: - yield name, None, exc + for extension, patterns in iteritems(self._patterns): + if matches_patterns(path, (extension,)): + for pattern, template in patterns: + converter = self.url_converter(name, template) + try: + content = pattern.sub(converter, content) + except ValueError as exc: + yield name, None, exc if hashed_file_exists: self.delete(hashed_name) # then save the processed result |
