From ef868f776c57c5770e7404baed0d80160f38b864 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 29 Jul 2024 23:13:46 +0100 Subject: [PATCH] Add LINK_CHECKER_IGNORED_URLS setting --- app/tasks/pkgtasks.py | 6 ++++++ config.example.cfg | 1 + 2 files changed, 7 insertions(+) diff --git a/app/tasks/pkgtasks.py b/app/tasks/pkgtasks.py index 4f902d0d..4dce26ef 100644 --- a/app/tasks/pkgtasks.py +++ b/app/tasks/pkgtasks.py @@ -24,6 +24,7 @@ from typing import Optional import requests import urllib3 +from app import app from sqlalchemy import or_, and_ from app.markdown import get_links, render_markdown @@ -125,6 +126,8 @@ def _url_exists(url: str) -> str: def _check_for_dead_links(package: Package) -> dict[str, str]: + ignored_urls = set(app.config.get("LINK_CHECKER_IGNORED_URLS", "")) + links: set[Optional[str]] = { package.repo, package.website, @@ -150,6 +153,9 @@ def _check_for_dead_links(package: Package) -> dict[str, str]: if url.scheme != "http" and url.scheme != "https": continue + if url.hostname in ignored_urls: + continue + res = _url_exists(link) if res != "": bad_urls[link] = res diff --git a/config.example.cfg b/config.example.cfg index 56a5c8c7..92708711 100644 --- a/config.example.cfg +++ b/config.example.cfg @@ -37,6 +37,7 @@ TEMPLATES_AUTO_RELOAD = False LOG_SQL = False BLOCKED_DOMAINS = [] +LINK_CHECKER_IGNORED_URLS = ["liberapay.com"] ADMIN_CONTACT_URL = "" MONITORING_URL = None