From 2b59a3082000842d980f9e19931949dbe5011229 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 30 Oct 2026 12:25:20 +0100 Subject: 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. --- webmentions_ssg/tasks/scanner.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'webmentions_ssg/tasks/scanner.py') 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 -- cgit v1.3.1