diff --git a/scripts/import_docs.py b/scripts/import_docs.py index 4e57543..328a4b2 100644 --- a/scripts/import_docs.py +++ b/scripts/import_docs.py @@ -64,7 +64,14 @@ def fetch_manifest(url: str, *, missing_ok: bool = False) -> dict | None: def check_publication(upstream: str, current: str) -> tuple[dict, bool]: manifest = fetch_manifest(upstream) - deployed = fetch_manifest(current, missing_ok=True) + try: + deployed = fetch_manifest(current, missing_ok=True) + except (ValueError, OSError) as error: + # The verified upstream can repair a missing or corrupt deployed marker. + print( + f"Deployed publication is unreadable; importing verified upstream: {error}" + ) + deployed = None return manifest, manifest != deployed diff --git a/scripts/test_import_docs.py b/scripts/test_import_docs.py index 91bea3c..cf8c1f8 100644 --- a/scripts/test_import_docs.py +++ b/scripts/test_import_docs.py @@ -138,6 +138,9 @@ def test_actual_http_checks_skip_unchanged_and_detect_same_tag_rebuild(self): _, changed = check_publication(base + "/upstream.json", base + "/current.json") self.assertTrue(changed) (self.root / "current.json").write_text("not JSON") + _, changed = check_publication(base + "/upstream.json", base + "/current.json") + self.assertTrue(changed) + (self.root / "upstream.json").write_text("not JSON") with self.assertRaises(ValueError): check_publication(base + "/upstream.json", base + "/current.json")