fix: handle failures fetching rsf list

This commit is contained in:
Iain Learmonth 2026-05-21 15:46:25 +01:00
parent ac03da59dc
commit 97fc9a5ab9

View file

@ -1,3 +1,5 @@
import logging
import requests import requests
from src.database import get_db_session from src.database import get_db_session
@ -7,10 +9,16 @@ from src.utils import repeat_every
@repeat_every(seconds=600) @repeat_every(seconds=600)
def update_rsf_mirrors(): def update_rsf_mirrors():
with get_db_session() as db: try:
r = requests.get( r = requests.get(
"https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json" "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json",
timeout = 30,
) )
r.raise_for_status()
mirrors = r.json() 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 refresh_mirrors(db, -2, mirrors) # Tracking as hardcoded pool -2
db.commit() db.commit()