Mercurial > piecrust2
comparison piecrust/cache.py @ 424:5feb71d31a4f
internal: Fix caches being orphaned from their directory.
After clearing caches, the instances in memory don't have a file-system
directory anymore. This means that either caching data would crash the app,
or, in the case of baking a site, would make the workers create the directory
but collide randomly while doing so at the same time.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 25 Jun 2015 14:51:12 -0700 |
parents | ff6cc43fb40c |
children | 61d606fbc313 |
comparison
equal
deleted
inserted
replaced
423:f4f5685019a2 | 424:5feb71d31a4f |
---|---|
44 def clearCache(self, name): | 44 def clearCache(self, name): |
45 cache_dir = self.getCacheDir(name) | 45 cache_dir = self.getCacheDir(name) |
46 if os.path.isdir(cache_dir): | 46 if os.path.isdir(cache_dir): |
47 logger.debug("Cleaning cache: %s" % cache_dir) | 47 logger.debug("Cleaning cache: %s" % cache_dir) |
48 shutil.rmtree(cache_dir) | 48 shutil.rmtree(cache_dir) |
49 | |
50 # Re-create the cache-dir because now our Cache instance points | |
51 # to a directory that doesn't exist anymore. | |
52 os.makedirs(cache_dir, 0o755) | |
49 | 53 |
50 def clearCaches(self, except_names=None): | 54 def clearCaches(self, except_names=None): |
51 for name in self.getCacheNames(except_names=except_names): | 55 for name in self.getCacheNames(except_names=except_names): |
52 self.clearCache(name) | 56 self.clearCache(name) |
53 | 57 |