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.
This commit is contained in:
parent
c2e1ecb4b1
commit
1c1a229632
|
@ -189,8 +189,8 @@ class CachedFilesMixin(object):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
|
|
||||||
# delete cache of all handled paths
|
# where to store the new paths
|
||||||
self.cache.delete_many([self.cache_key(path) for path in paths])
|
hashed_paths = {}
|
||||||
|
|
||||||
# build a list of adjustable files
|
# build a list of adjustable files
|
||||||
matches = lambda path: matches_patterns(path, self._patterns.keys())
|
matches = lambda path: matches_patterns(path, self._patterns.keys())
|
||||||
|
@ -239,9 +239,12 @@ class CachedFilesMixin(object):
|
||||||
hashed_name = force_unicode(saved_name.replace('\\', '/'))
|
hashed_name = force_unicode(saved_name.replace('\\', '/'))
|
||||||
|
|
||||||
# and then set the cache accordingly
|
# 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
|
yield name, hashed_name, processed
|
||||||
|
|
||||||
|
# Finally set the cache
|
||||||
|
self.cache.set_many(hashed_paths)
|
||||||
|
|
||||||
|
|
||||||
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage):
|
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue