Mercurial > piecrust2
comparison piecrust/pipelines/base.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 | fa489c5e829e |
children | 5f97b5b59dfe |
comparison
equal
deleted
inserted
replaced
1050:e0796761cdcc | 1051:971b4d67e82a |
---|---|
281 os.remove(path) | 281 os.remove(path) |
282 except FileNotFoundError: | 282 except FileNotFoundError: |
283 pass | 283 pass |
284 logger.info('[delete] %s' % path) | 284 logger.info('[delete] %s' % path) |
285 | 285 |
286 def collapseRecords(self): | 286 def collapseRecords(self, keep_unused_records=False): |
287 seen_records = [] | |
287 for ppinfo in self.getPipelineInfos(): | 288 for ppinfo in self.getPipelineInfos(): |
288 ctx = PipelineCollapseRecordContext(ppinfo.record_history) | 289 ctx = PipelineCollapseRecordContext(ppinfo.record_history) |
289 ppinfo.pipeline.collapseRecords(ctx) | 290 ppinfo.pipeline.collapseRecords(ctx) |
291 seen_records.append(ppinfo.pipeline.record_name) | |
292 | |
293 if keep_unused_records: | |
294 cur_recs = self.record_histories.current | |
295 prev_recs = self.record_histories.previous | |
296 for prev_rec in prev_recs.records: | |
297 if prev_rec.name in seen_records: | |
298 continue | |
299 | |
300 logger.debug("Keeping record: %s" % prev_rec.name) | |
301 cur_recs.records.append(prev_rec) | |
290 | 302 |
291 def shutdownPipelines(self): | 303 def shutdownPipelines(self): |
292 for ppinfo in self.getPipelineInfos(): | 304 for ppinfo in self.getPipelineInfos(): |
293 ppinfo.pipeline.shutdown() | 305 ppinfo.pipeline.shutdown() |
294 | 306 |