From 98c072ca5f2aa5d452f927acc397166be6572dab Mon Sep 17 00:00:00 2001 From: Peiwen Jin <48341438+alimand@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:59:08 +0100 Subject: [PATCH] detect HTML code != 200 and log ERROR rather than creating fake downloads (#34) Co-authored-by: PEIWEN JIN --- 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: