From 97fc9a5ab9c4649bb0c035766f7b7dcb13789364 Mon Sep 17 00:00:00 2001 From: irl Date: Thu, 21 May 2026 15:46:25 +0100 Subject: [PATCH] fix: handle failures fetching rsf list --- src/mirrors/tasks.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/mirrors/tasks.py b/src/mirrors/tasks.py index 614f94e..f0bc7f2 100644 --- a/src/mirrors/tasks.py +++ b/src/mirrors/tasks.py @@ -1,3 +1,5 @@ +import logging + import requests from src.database import get_db_session @@ -7,10 +9,16 @@ from src.utils import repeat_every @repeat_every(seconds=600) def update_rsf_mirrors(): - with get_db_session() as db: - r = requests.get( - "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json" - ) - mirrors = r.json() - refresh_mirrors(db, -2, mirrors) # Tracking as hardcoded pool -2 - db.commit() + try: + r = requests.get( + "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json", + timeout = 30, + ) + r.raise_for_status() + mirrors = r.json() + except (requests.RequestException, ValueError) as e: + logging.exception(e) + return + with get_db_session() as db: + refresh_mirrors(db, -2, mirrors) # Tracking as hardcoded pool -2 + db.commit() \ No newline at end of file