diff options
| author | Jannis Leidel <jannis@leidel.info> | 2012-05-10 18:29:34 +0200 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2012-05-10 18:30:46 +0200 |
| commit | 35423f6fb1bf6f8dcde657debbe981943474985b (patch) | |
| tree | 554f7d8baeecbbce919e8ed877e75ecc4cb3b4db | |
| parent | ffe620f20332c292ac94f169e23910a39f4e9ae9 (diff) | |
[1.4.X] Set the post process cache when finished instead of one by one.
This should prevent a race condition if running collectstatic is
canceled or its cache is accessed from other processes, leaving the
cache in a corrupt state.
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index c000f97d05..7e35add65a 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -190,8 +190,8 @@ class CachedFilesMixin(object): if dry_run: return - # delete cache of all handled paths - self.cache.delete_many([self.cache_key(path) for path in paths]) + # where to store the new paths + hashed_paths = {} # build a list of adjustable files matches = lambda path: matches_patterns(path, self._patterns.keys()) @@ -240,9 +240,12 @@ class CachedFilesMixin(object): hashed_name = force_unicode(saved_name.replace('\\', '/')) # and then set the cache accordingly - self.cache.set(self.cache_key(name), hashed_name) + hashed_paths[self.cache_key(name)] = hashed_name yield name, hashed_name, processed + # Finally set the cache + self.cache.set_many(hashed_paths) + class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): """ |
