From 37d36e6672c4943c19a3ee0c4e5be471428611ed Mon Sep 17 00:00:00 2001 From: James Knight Date: Sat, 24 Feb 2024 10:34:13 -0500 Subject: [PATCH] builder: avoid unchanged page cache checks if we have legacy pages Before attempting to cleanup any detected legacy pages from a target Confluence instance, the builder will check to see if any unchanged documents exist (pages that did not trigger an update and we not removed from the internal legacy list), and remove them from the legacy pages list if our cache detects it was already published. However, this logic assumes we have populated a legacy pages list ahead of time, which may not have happened if we are not configured for any cleaning. This commit adjusts the unchanged pages check to only occur if we have populated a legacy pages list to check on. Signed-off-by: James Knight --- sphinxcontrib/confluencebuilder/builder.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sphinxcontrib/confluencebuilder/builder.py b/sphinxcontrib/confluencebuilder/builder.py index 8be1772a..4719b63e 100644 --- a/sphinxcontrib/confluencebuilder/builder.py +++ b/sphinxcontrib/confluencebuilder/builder.py @@ -800,14 +800,16 @@ def to_asset_name(asset): except OSError as err: self.warn(f'error reading asset {key}: {err}') - # if we have documents that were not changes (and therefore, not + # if we have documents that were not changed (and therefore, not # needing to be republished), assume any cached publish page ids # are still valid and remove them from the legacy pages list - other_docs = self.env.all_docs.keys() - set(self.publish_docnames) - for unchanged_doc in other_docs: - lpid = self._cache_info.last_page_id(unchanged_doc) - if lpid is not None and lpid in self.legacy_pages: - self.legacy_pages.remove(lpid) + if self.legacy_pages: + all_docnames = self.env.all_docs.keys() + other_docnames = all_docnames - set(self.publish_docnames) + for unchanged_docname in other_docnames: + lpid = self._cache_info.last_page_id(unchanged_docname) + if lpid is not None and lpid in self.legacy_pages: + self.legacy_pages.remove(lpid) self.publish_cleanup() self.publish_finalize()