Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17806 -- Fixed off-by-n error in the CachedStaticFilesStorage …

…that prevented it from finding files in nested directories. Many thanks to lpetre.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e88a65660f8d114b8c5e8670f228af7f4bdd81a0 1 parent 746987f
Jannis Leidel authored March 02, 2012
2  django/contrib/staticfiles/storage.py
@@ -160,7 +160,7 @@ def converter(matchobj):
160 160
                 if sub_level:
161 161
                     if sub_level == 1:
162 162
                         parent_level -= 1
163  
-                    start, end = parent_level, sub_level - 1
  163
+                    start, end = parent_level, 1
164 164
                 else:
165 165
                     start, end = 1, sub_level - 1
166 166
             joined_result = '/'.join(name_parts[:-start] + url_parts[end:])
3  tests/regressiontests/staticfiles_tests/project/documents/cached/absolute.css
... ...
@@ -1 +1,4 @@
1 1
 @import url("/static/cached/styles.css");
  2
+body {
  3
+    background: #d3d6d8 url(/static/cached/img/relative.png);
  4
+}
3  tests/regressiontests/staticfiles_tests/tests.py
@@ -416,11 +416,12 @@ def test_path_with_querystring_and_fragment(self):
416 416
 
417 417
     def test_template_tag_absolute(self):
418 418
         relpath = self.cached_file_path("cached/absolute.css")
419  
-        self.assertEqual(relpath, "cached/absolute.cc80cb5e2eb1.css")
  419
+        self.assertEqual(relpath, "cached/absolute.23f087ad823a.css")
420 420
         with storage.staticfiles_storage.open(relpath) as relfile:
421 421
             content = relfile.read()
422 422
             self.assertNotIn("/static/cached/styles.css", content)
423 423
             self.assertIn("/static/cached/styles.93b1147e8552.css", content)
  424
+            self.assertIn('/static/cached/img/relative.acae32e4532b.png', content)
424 425
 
425 426
     def test_template_tag_denorm(self):
426 427
         relpath = self.cached_file_path("cached/denorm.css")

0 notes on commit e88a656

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