comparison piecrust/baking/baker.py @ 45:efd0d3bacc9e

Don't recursively clean the cache.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 21 Aug 2014 23:09:31 -0700
parents 9e058e221108
children fce061f8c2ed
comparison
equal deleted inserted replaced
44:a62452ab5080 45:efd0d3bacc9e
252 if not os.path.isdir(self.out_dir): 252 if not os.path.isdir(self.out_dir):
253 os.makedirs(self.out_dir, 0o755) 253 os.makedirs(self.out_dir, 0o755)
254 254
255 # Load/create the bake record. 255 # Load/create the bake record.
256 record = TransitionalBakeRecord() 256 record = TransitionalBakeRecord()
257 record_cache = self.app.cache.getCache('bake_r') 257 record_cache = self.app.cache.getCache('baker')
258 record_name = (hashlib.md5(self.out_dir.encode('utf8')).hexdigest() + 258 record_name = (hashlib.md5(self.out_dir.encode('utf8')).hexdigest() +
259 '.record') 259 '.record')
260 if not self.force and record_cache.has(record_name): 260 if not self.force and record_cache.has(record_name):
261 t = time.clock() 261 t = time.clock()
262 record.loadPrevious(record_cache.getCachePath(record_name)) 262 record.loadPrevious(record_cache.getCachePath(record_name))
326 max_time = max(max_time, os.path.getmtime(full_fn)) 326 max_time = max(max_time, os.path.getmtime(full_fn))
327 if max_time >= record.previous.bake_time: 327 if max_time >= record.previous.bake_time:
328 reason = "templates modified" 328 reason = "templates modified"
329 329
330 if reason is not None: 330 if reason is not None:
331 cache_dir = self.app.cache_dir 331 cache_dir = self.app.cache.getCacheDir('baker')
332 if os.path.isdir(cache_dir): 332 if os.path.isdir(cache_dir):
333 logger.debug("Cleaning cache: %s" % cache_dir) 333 logger.debug("Cleaning baker cache: %s" % cache_dir)
334 shutil.rmtree(cache_dir) 334 shutil.rmtree(cache_dir)
335 self.force = True 335 self.force = True
336 logger.info(format_timed(start_time, 336 logger.info(format_timed(start_time,
337 "cleaned cache (reason: %s)" % reason)) 337 "cleaned cache (reason: %s)" % reason))
338 else: 338 else:
339 logger.debug(format_timed(start_time, "cache is assumed valid", 339 logger.debug(format_timed(start_time, "cache is assumed valid",
340 colored=False)) 340 colored=False))