aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg/tasks')
-rw-r--r--webmentions_ssg/tasks/scanner.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/webmentions_ssg/tasks/scanner.py b/webmentions_ssg/tasks/scanner.py
index 1f98702..9058b9b 100644
--- a/webmentions_ssg/tasks/scanner.py
+++ b/webmentions_ssg/tasks/scanner.py
@@ -14,6 +14,7 @@ from huey.exceptions import RetryTask, TaskLockedException
from sqlalchemy.orm import selectinload
from ..extensions import db, huey
+from ..models.scan_state import ScanState
from ..models.sources import SentWebmention, SourceDocument
from ..net import is_http_url
from .sender import send_webmention
@@ -304,6 +305,11 @@ def _scan_and_enqueue() -> None:
db.session.commit()
pending_count = enqueue_due_sends(scan_time)
+ # Mark a scan complete only after reconciliation and task enqueueing have
+ # succeeded. An inconclusive or interrupted scan keeps the previous value.
+ db.session.merge(ScanState(id=1, last_completed_at=datetime.now(UTC)))
+ db.session.commit()
+
current_app.logger.info(
"Webmention source scan complete: %d sources scanned, "
"%d missing sources, %d pending sends",