diff piecrust/pipelines/_pagebaker.py @ 1132:3bcb2d446397

fix: Correctly invalidate pages that use dirtied sources.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 16 Apr 2018 22:22:54 -0700
parents 298b07a899b5
children 5f97b5b59dfe
line wrap: on
line diff
--- a/piecrust/pipelines/_pagebaker.py	Wed Feb 28 20:44:23 2018 -0800
+++ b/piecrust/pipelines/_pagebaker.py	Mon Apr 16 22:22:54 2018 -0700
@@ -69,12 +69,14 @@
         with open(out_path, 'w', encoding='utf8') as fp:
             fp.write(content)
 
-    def bake(self, page, prev_entry, force=False):
+    def bake(self, page, prev_entry,
+             force_segments=False, force_layout=False):
         cur_sub = 1
         has_more_subs = True
         app = self.app
         out_dir = self.out_dir
-        force_bake = self.force or force
+        force_segments = self.force or force_segments
+        force_layout = self.force or force_layout
         pretty_urls = page.config.get('pretty_urls', self.pretty_urls)
 
         rendered_subs = []
@@ -99,7 +101,8 @@
                     pass
 
             # Figure out if we need to bake this page.
-            bake_status = _get_bake_status(page, out_path, force_bake,
+            bake_status = _get_bake_status(page, out_path,
+                                           force_segments, force_layout,
                                            prev_sub_entry, cur_sub_entry)
 
             # If this page didn't bake because it's already up-to-date.
@@ -207,20 +210,19 @@
 STATUS_INVALIDATE_AND_BAKE = 2
 
 
-def _get_bake_status(page, out_path, force, prev_sub_entry, cur_sub_entry):
+def _get_bake_status(page, out_path, force_segments, force_layout,
+                     prev_sub_entry, cur_sub_entry):
+    # Easy tests.
+    if force_segments:
+        return STATUS_INVALIDATE_AND_BAKE
+    if force_layout:
+        return STATUS_BAKE
+
     # Figure out if we need to invalidate or force anything.
     status = _compute_force_flags(prev_sub_entry, cur_sub_entry)
     if status != STATUS_CLEAN:
         return status
 
-    # Easy test.
-    if force:
-        cur_sub_entry['flags'] |= \
-            SubPageFlags.FLAG_FORCED_BY_GENERAL_FORCE
-        # We need to invalidate any cache we have on this page because
-        # it's being forced, so something important has changed somehow.
-        return STATUS_INVALIDATE_AND_BAKE
-
     # Check for up-to-date outputs.
     in_path_time = page.content_mtime
     try: