Mercurial > piecrust2
changeset 333:91b07f9efdc1
bake: Use a rotating bake record.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 03 Apr 2015 08:44:21 -0700 |
parents | d8c28e496bb3 |
children | b034f6f15e22 |
files | piecrust/baking/baker.py |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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()