comparison piecrust/baking/baker.py @ 333:91b07f9efdc1

bake: Use a rotating bake record.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 03 Apr 2015 08:44:21 -0700
parents 65e6d72f3877
children b034f6f15e22
comparison
equal deleted inserted replaced
332:d8c28e496bb3 333:91b07f9efdc1
50 os.makedirs(self.out_dir, 0o755) 50 os.makedirs(self.out_dir, 0o755)
51 51
52 # Load/create the bake record. 52 # Load/create the bake record.
53 record = TransitionalBakeRecord() 53 record = TransitionalBakeRecord()
54 record_cache = self.app.cache.getCache('baker') 54 record_cache = self.app.cache.getCache('baker')
55 record_name = ( 55 record_id = hashlib.md5(self.out_dir.encode('utf8')).hexdigest()
56 hashlib.md5(self.out_dir.encode('utf8')).hexdigest() + 56 record_name = record_id + '.record'
57 '.record')
58 if not self.force and record_cache.has(record_name): 57 if not self.force and record_cache.has(record_name):
59 t = time.clock() 58 t = time.clock()
60 record.loadPrevious(record_cache.getCachePath(record_name)) 59 record.loadPrevious(record_cache.getCachePath(record_name))
61 logger.debug(format_timed( 60 logger.debug(format_timed(
62 t, 'loaded previous bake record', 61 t, 'loaded previous bake record',
85 # Bake taxonomies. 84 # Bake taxonomies.
86 self._bakeTaxonomies(record) 85 self._bakeTaxonomies(record)
87 86
88 # Delete files from the output. 87 # Delete files from the output.
89 self._handleDeletetions(record) 88 self._handleDeletetions(record)
89
90 # Backup previous records.
91 for i in range(8, -1, -1):
92 suffix = '' if i == 0 else '.%d' % i
93 record_path = record_cache.getCachePath(
94 '%s%s.record' % (record_id, suffix))
95 if os.path.exists(record_path):
96 record_path_next = record_cache.getCachePath(
97 '%s.%s.record' % (record_id, i + 1))
98 if os.path.exists(record_path_next):
99 os.remove(record_path_next)
100 os.rename(record_path, record_path_next)
90 101
91 # Save the bake record. 102 # Save the bake record.
92 t = time.clock() 103 t = time.clock()
93 record.current.bake_time = time.time() 104 record.current.bake_time = time.time()
94 record.current.out_dir = self.out_dir 105 record.current.out_dir = self.out_dir