Author: jezdez
Date: 2012-02-16 06:40:32 -0800 (Thu, 16 Feb 2012)
New Revision: 17535

Modified:
   django/trunk/django/contrib/staticfiles/storage.py
   django/trunk/tests/regressiontests/staticfiles_tests/tests.py
Log:
Fixed #17689 -- Stopped the CachedStaticFilesStorage from trying to hash paths 
that aren't files.

Modified: django/trunk/django/contrib/staticfiles/storage.py
===================================================================
--- django/trunk/django/contrib/staticfiles/storage.py  2012-02-16 11:45:57 UTC 
(rev 17534)
+++ django/trunk/django/contrib/staticfiles/storage.py  2012-02-16 14:40:32 UTC 
(rev 17535)
@@ -105,13 +105,16 @@
             hashed_name, fragment = name, ''
         else:
             clean_name, fragment = urldefrag(name)
-            cache_key = self.cache_key(name)
-            hashed_name = self.cache.get(cache_key)
-            if hashed_name is None:
-                hashed_name = self.hashed_name(clean_name).replace('\\', '/')
-                # set the cache if there was a miss
-                # (e.g. if cache server goes down)
-                self.cache.set(cache_key, hashed_name)
+            if urlsplit(clean_name).path.endswith('/'):  # don't hash paths
+                hashed_name = name
+            else:
+                cache_key = self.cache_key(name)
+                hashed_name = self.cache.get(cache_key)
+                if hashed_name is None:
+                    hashed_name = self.hashed_name(clean_name).replace('\\', 
'/')
+                    # set the cache if there was a miss
+                    # (e.g. if cache server goes down)
+                    self.cache.set(cache_key, hashed_name)
 
         final_url = super(CachedFilesMixin, self).url(hashed_name)
 

Modified: django/trunk/tests/regressiontests/staticfiles_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/staticfiles_tests/tests.py       
2012-02-16 11:45:57 UTC (rev 17534)
+++ django/trunk/tests/regressiontests/staticfiles_tests/tests.py       
2012-02-16 14:40:32 UTC (rev 17535)
@@ -317,6 +317,10 @@
                                  "/static/test/file.ea5bccaf16d5.txt")
         self.assertStaticRenders("cached/styles.css",
                                  "/static/cached/styles.93b1147e8552.css")
+        self.assertStaticRenders("path/",
+                                 "/static/path/")
+        self.assertStaticRenders("path/?query",
+                                 "/static/path/?query")
 
     def test_template_tag_simple_content(self):
         relpath = self.cached_file_path("cached/styles.css")

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to