Ticket #17689: ticket-17689.diff

File ticket-17689.diff, 2.2 KB (added by tkaemming, 3 years ago)
  • django/contrib/staticfiles/storage.py

    diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
    index 0293363..ac83f52 100644
    a b class CachedFilesMixin(object): 
    105105            hashed_name, fragment = name, ''
    106106        else:
    107107            clean_name, fragment = urldefrag(name)
    108             cache_key = self.cache_key(name)
    109             hashed_name = self.cache.get(cache_key)
    110             if hashed_name is None:
    111                 hashed_name = self.hashed_name(clean_name).replace('\\', '/')
    112                 # set the cache if there was a miss
    113                 # (e.g. if cache server goes down)
    114                 self.cache.set(cache_key, hashed_name)
     108            if urlsplit(clean_name).path.endswith('/'):  # don't hash paths
     109                hashed_name = name
     110            else:
     111                cache_key = self.cache_key(name)
     112                hashed_name = self.cache.get(cache_key)
     113                if hashed_name is None:
     114                    hashed_name = self.hashed_name(clean_name).replace('\\', '/')
     115                    # set the cache if there was a miss
     116                    # (e.g. if cache server goes down)
     117                    self.cache.set(cache_key, hashed_name)
    115118
    116119        final_url = super(CachedFilesMixin, self).url(hashed_name)
    117120
  • tests/regressiontests/staticfiles_tests/tests.py

    diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py
    index 680027b..9834885 100644
    a b class TestCollectionCachedStorage(BaseCollectionTestCase, 
    317317                                 "/static/test/file.ea5bccaf16d5.txt")
    318318        self.assertStaticRenders("cached/styles.css",
    319319                                 "/static/cached/styles.93b1147e8552.css")
     320        self.assertStaticRenders("path/",
     321                                 "/static/path/")
     322        self.assertStaticRenders("path/?query",
     323                                 "/static/path/?query")
    320324
    321325    def test_template_tag_simple_content(self):
    322326        relpath = self.cached_file_path("cached/styles.css")
Back to Top