diff 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
line wrap: on
line diff
--- a/piecrust/baking/baker.py	Fri Jan 26 18:02:07 2018 -0800
+++ b/piecrust/baking/baker.py	Fri Jan 26 18:05:02 2018 -0800
@@ -31,7 +31,8 @@
                  allowed_pipelines=None,
                  forbidden_pipelines=None,
                  allowed_sources=None,
-                 rotate_bake_records=True):
+                 rotate_bake_records=True,
+                 keep_unused_records=False):
         self.appfactory = appfactory
         self.app = app
         self.out_dir = out_dir
@@ -40,6 +41,7 @@
         self.forbidden_pipelines = forbidden_pipelines
         self.allowed_sources = allowed_sources
         self.rotate_bake_records = rotate_bake_records
+        self.keep_unused_records = keep_unused_records
 
     def bake(self):
         start_time = time.perf_counter()
@@ -108,7 +110,7 @@
         # Handle deletions, collapse records, etc.
         ppmngr.postJobRun()
         ppmngr.deleteStaleOutputs()
-        ppmngr.collapseRecords()
+        ppmngr.collapseRecords(self.keep_unused_records)
 
         # All done with the workers. Close the pool and get reports.
         pool_stats = pool.close()