aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks/scanner.py
diff options
context:
space:
mode:
authorDennis Fink2026-10-30 12:25:20 +0100
committerDennis Fink2026-10-30 12:25:20 +0100
commit2b59a3082000842d980f9e19931949dbe5011229 (patch)
treef3efe28025f8a0b8498ab1280d2b66949c64e36d /webmentions_ssg/tasks/scanner.py
parent89bff71238d06178528515e45cc00bcc8d70d663 (diff)
downloadwebmentions-ssg-2b59a3082000842d980f9e19931949dbe5011229.tar.gz
webmentions-ssg-2b59a3082000842d980f9e19931949dbe5011229.zip
fix(sender): ignore inconclusive empty scans
Treat scans with no successfully processed source pages as inconclusive so a temporary empty or partially rebuilt output directory cannot mark every source deleted or trigger removal Webmentions. Defer pending sends until at least one source is scanned successfully.
Diffstat (limited to 'webmentions_ssg/tasks/scanner.py')
-rw-r--r--webmentions_ssg/tasks/scanner.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/webmentions_ssg/tasks/scanner.py b/webmentions_ssg/tasks/scanner.py
index e8149ba..7e163f7 100644
--- a/webmentions_ssg/tasks/scanner.py
+++ b/webmentions_ssg/tasks/scanner.py
@@ -406,7 +406,9 @@ def scan_sources() -> None:
Scan generated source documents and queue pending Webmentions.
New and changed sources are persisted, missing sources are marked as deleted,
- and Webmentions requiring processing are queued for sending.
+ and Webmentions requiring processing are queued for sending. A scan that
+ successfully processes no sources is treated as inconclusive: it neither
+ marks sources deleted nor queues Webmentions.
:raises RuntimeError: If the configured source directory or base URL is
invalid.
@@ -498,6 +500,17 @@ def scan_sources() -> None:
except SourceScanError as exc:
current_app.logger.warning("Could not scan source %s: %s", index_path, exc)
+ # A static-site generator can temporarily empty its output directory while
+ # rebuilding. With no successfully scanned pages, absence is not evidence
+ # of deletion; do not generate removals or send pending Webmentions that
+ # might be verified while the site is unavailable.
+ if scanned_count == 0:
+ current_app.logger.warning(
+ "No source documents successfully scanned; "
+ "skipping deletion detection and Webmention sends"
+ )
+ return
+
for path, source in sources_by_path.items():
if source.deleted_at is not None or path in seen_paths:
continue