Mercurial > piecrust2
changeset 45:efd0d3bacc9e
Don't recursively clean the cache.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 21 Aug 2014 23:09:31 -0700 |
parents | a62452ab5080 |
children | 99dea56238af |
files | piecrust/baking/baker.py piecrust/cache.py piecrust/commands/builtin/baking.py |
diffstat | 3 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/baking/baker.py Thu Aug 21 22:52:18 2014 -0700 +++ b/piecrust/baking/baker.py Thu Aug 21 23:09:31 2014 -0700 @@ -254,7 +254,7 @@ # Load/create the bake record. record = TransitionalBakeRecord() - record_cache = self.app.cache.getCache('bake_r') + record_cache = self.app.cache.getCache('baker') record_name = (hashlib.md5(self.out_dir.encode('utf8')).hexdigest() + '.record') if not self.force and record_cache.has(record_name): @@ -328,11 +328,11 @@ reason = "templates modified" if reason is not None: - cache_dir = self.app.cache_dir + cache_dir = self.app.cache.getCacheDir('baker') if os.path.isdir(cache_dir): - logger.debug("Cleaning cache: %s" % cache_dir) + logger.debug("Cleaning baker cache: %s" % cache_dir) shutil.rmtree(cache_dir) - self.force = True + self.force = True logger.info(format_timed(start_time, "cleaned cache (reason: %s)" % reason)) else:
--- a/piecrust/cache.py Thu Aug 21 22:52:18 2014 -0700 +++ b/piecrust/cache.py Thu Aug 21 23:09:31 2014 -0700 @@ -32,6 +32,9 @@ self.caches[name] = c return c + def getCacheDir(self, name): + return os.path.join(self.base_dir, name) + class SimpleCache(object): def __init__(self, base_dir): @@ -72,6 +75,7 @@ cache_dir = os.path.dirname(cache_path) if not os.path.isdir(cache_dir): os.makedirs(cache_dir, 0o755) + logger.debug("Writing cache: %s" % cache_path) with codecs.open(cache_path, 'w', 'utf-8') as fp: fp.write(content)
--- a/piecrust/commands/builtin/baking.py Thu Aug 21 22:52:18 2014 -0700 +++ b/piecrust/commands/builtin/baking.py Thu Aug 21 23:09:31 2014 -0700 @@ -66,7 +66,7 @@ def run(self, ctx): out_dir = ctx.args.output or os.path.join(ctx.app.root_dir, '_counter') - record_cache = ctx.app.cache.getCache('bake_r') + record_cache = ctx.app.cache.getCache('baker') record_name = hashlib.md5(out_dir.encode('utf8')).hexdigest() + '.record' if not record_cache.has(record_name): raise Exception("No record has been created for this output path. "