Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17689 -- Stopped the CachedStaticFilesStorage from trying to h…

…ash paths that aren't files.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17535 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 758a0cd0f1c646abf6f7d4f01850d3729ad603e0 1 parent 8f4d12e
Jannis Leidel authored February 16, 2012
17  django/contrib/staticfiles/storage.py
@@ -105,13 +105,16 @@ def url(self, name, force=False):
105 105
             hashed_name, fragment = name, ''
106 106
         else:
107 107
             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)
115 118
 
116 119
         final_url = super(CachedFilesMixin, self).url(hashed_name)
117 120
 
4  tests/regressiontests/staticfiles_tests/tests.py
@@ -317,6 +317,10 @@ def test_template_tag_return(self):
317 317
                                  "/static/test/file.ea5bccaf16d5.txt")
318 318
         self.assertStaticRenders("cached/styles.css",
319 319
                                  "/static/cached/styles.93b1147e8552.css")
  320
+        self.assertStaticRenders("path/",
  321
+                                 "/static/path/")
  322
+        self.assertStaticRenders("path/?query",
  323
+                                 "/static/path/?query")
320 324
 
321 325
     def test_template_tag_simple_content(self):
322 326
         relpath = self.cached_file_path("cached/styles.css")

0 notes on commit 758a0cd

Please sign in to comment.
Something went wrong with that request. Please try again.