From c07c2f821110d2e1e3e9b149076b955d244b24c0 Mon Sep 17 00:00:00 2001 From: PEIWEN JIN Date: Fri, 6 Dec 2024 10:41:49 +0100 Subject: [PATCH] detect HTML code != 200 and log ERROR rather than creating fake downloads --- wis2downloader/downloader/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wis2downloader/downloader/__init__.py b/wis2downloader/downloader/__init__.py index a05717b..9b4a881 100644 --- a/wis2downloader/downloader/__init__.py +++ b/wis2downloader/downloader/__init__.py @@ -182,6 +182,12 @@ def process_job(self, job) -> None: response = None try: response = self.http.request('GET', _url) + # Check the response status code + if response.status != 200: + LOGGER.error(f"Error downloading {_url}, received status code: {response.status}") + # Increment failed download counter + FAILED_DOWNLOADS.labels(topic=topic, centre_id=centre_id).inc(1) + return # Get the filesize in KB filesize = len(response.data) except Exception as e: