comparison piecrust/baking/baker.py @ 1051:971b4d67e82a

serve: Fix problems with assets disappearing between servings. When an asset file changes, its source's pipeline is re-run. But that created a bake record that only had that pipeline's output, so the other outputs were incorrectly considered empty and therefore any stray files were removed. Now we copy over bake records for the pipelines we don't run.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 26 Jan 2018 18:05:02 -0800
parents e0796761cdcc
children 5f97b5b59dfe
comparison
equal deleted inserted replaced
1050:e0796761cdcc 1051:971b4d67e82a
29 def __init__(self, appfactory, app, out_dir, *, 29 def __init__(self, appfactory, app, out_dir, *,
30 force=False, 30 force=False,
31 allowed_pipelines=None, 31 allowed_pipelines=None,
32 forbidden_pipelines=None, 32 forbidden_pipelines=None,
33 allowed_sources=None, 33 allowed_sources=None,
34 rotate_bake_records=True): 34 rotate_bake_records=True,
35 keep_unused_records=False):
35 self.appfactory = appfactory 36 self.appfactory = appfactory
36 self.app = app 37 self.app = app
37 self.out_dir = out_dir 38 self.out_dir = out_dir
38 self.force = force 39 self.force = force
39 self.allowed_pipelines = allowed_pipelines 40 self.allowed_pipelines = allowed_pipelines
40 self.forbidden_pipelines = forbidden_pipelines 41 self.forbidden_pipelines = forbidden_pipelines
41 self.allowed_sources = allowed_sources 42 self.allowed_sources = allowed_sources
42 self.rotate_bake_records = rotate_bake_records 43 self.rotate_bake_records = rotate_bake_records
44 self.keep_unused_records = keep_unused_records
43 45
44 def bake(self): 46 def bake(self):
45 start_time = time.perf_counter() 47 start_time = time.perf_counter()
46 48
47 # Setup baker. 49 # Setup baker.
106 self._bakeRealms(pool, ppmngr, record_histories) 108 self._bakeRealms(pool, ppmngr, record_histories)
107 109
108 # Handle deletions, collapse records, etc. 110 # Handle deletions, collapse records, etc.
109 ppmngr.postJobRun() 111 ppmngr.postJobRun()
110 ppmngr.deleteStaleOutputs() 112 ppmngr.deleteStaleOutputs()
111 ppmngr.collapseRecords() 113 ppmngr.collapseRecords(self.keep_unused_records)
112 114
113 # All done with the workers. Close the pool and get reports. 115 # All done with the workers. Close the pool and get reports.
114 pool_stats = pool.close() 116 pool_stats = pool.close()
115 current_records.stats = _merge_execution_stats(stats, *pool_stats) 117 current_records.stats = _merge_execution_stats(stats, *pool_stats)
116 118