# HG changeset patch # User Ludovic Chabant # Date 1428075861 25200 # Node ID 91b07f9efdc1ef7e1841e027a162fdbedfb82aec # Parent d8c28e496bb30466ecdbb4dfc7c584a818ef367f bake: Use a rotating bake record. diff -r d8c28e496bb3 -r 91b07f9efdc1 piecrust/baking/baker.py --- a/piecrust/baking/baker.py Wed Apr 01 00:35:04 2015 -0700 +++ b/piecrust/baking/baker.py Fri Apr 03 08:44:21 2015 -0700 @@ -52,9 +52,8 @@ # Load/create the bake record. record = TransitionalBakeRecord() record_cache = self.app.cache.getCache('baker') - record_name = ( - hashlib.md5(self.out_dir.encode('utf8')).hexdigest() + - '.record') + record_id = hashlib.md5(self.out_dir.encode('utf8')).hexdigest() + record_name = record_id + '.record' if not self.force and record_cache.has(record_name): t = time.clock() record.loadPrevious(record_cache.getCachePath(record_name)) @@ -88,6 +87,18 @@ # Delete files from the output. self._handleDeletetions(record) + # Backup previous records. + for i in range(8, -1, -1): + suffix = '' if i == 0 else '.%d' % i + record_path = record_cache.getCachePath( + '%s%s.record' % (record_id, suffix)) + if os.path.exists(record_path): + record_path_next = record_cache.getCachePath( + '%s.%s.record' % (record_id, i + 1)) + if os.path.exists(record_path_next): + os.remove(record_path_next) + os.rename(record_path, record_path_next) + # Save the bake record. t = time.clock() record.current.bake_time = time.time()