Siril catalog downloader fails.

Catalog downloader fails quite often, usually because the server returns a “HTTP 429” error message, but with a status code of 200. This results in faulty sha256 sums, and failed downloads. Since I am not able to register to gitlab (I am neither allowed, nor willing to use my work email for such purposes) here is a patch, that works around it by validating the downloaded sha256 data, and also allowing the end-user to download the data manually, store it in the local siril folder, and then allow siril to validate, and decompress the data:

From 8311dc37d0e9572372829162265f1015b3c1de93 Mon Sep 17 00:00:00 2001
From: Lehel Gyuro <lehel@freemail.hu>
Date: Fri, 26 Dec 2025 19:13:58 +0100
Subject: [PATCH] Fix astrometry download issues with err 429

Download often fails due to sha256 files not containing valid sha256
signatures, but html errors returned by the server as "HTTP 200"
messages.
Moved downloader from direct requests to the siril one. Added validating
of downloaded sha256sum files. Added possibility for the user to
download the files with a different tool, place them into the dir, and
let siril validat, and unpack the contents.
---
 core/Siril_Catalog_Installer.py | 37 +++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/core/Siril_Catalog_Installer.py b/core/Siril_Catalog_Installer.py
index 70a4ef7..34a10b4 100644
--- a/core/Siril_Catalog_Installer.py
+++ b/core/Siril_Catalog_Installer.py
@@ -34,6 +34,7 @@ import bz2
 import hashlib
 import math
 import os
+import os.path
 import platform
 import sys
 import ctypes
@@ -725,6 +726,15 @@ class SirilCatInstallerInterface(QMainWindow):
             print("Checksum verification succeeded.")
             return True
 
+    def verify_sha256sum_file(self, sha256sum_path):
+        with open(sha256sum_path, 'r', encoding='utf-8') as checksum_fp:
+            sha256sum_content = checksum_fp.readline()
+            if sha256sum_content.startswith("<html>"):
+                print(f"Verification of {sha256sum_path} failed.")
+                return False
+        print(f"Verification of {sha256sum_path} succeeded.")
+        return True
+
     def install_astrometry(self):
         """Install astrometry catalog"""
         reply = QMessageBox.question(
@@ -751,10 +761,15 @@ class SirilCatInstallerInterface(QMainWindow):
             try:
                 # Download the .sha256sum file
                 sha256sum_path = os.path.join(target_dir, shasumfile)
-                print(f"Downloading {sha256sum_url} to {sha256sum_path}...")
-                response = requests.get(sha256sum_url)
-                with open(sha256sum_path, 'wb') as f:
-                    f.write(response.content)
+                if os.path.exists(sha256sum_path):
+                    print("Existing checksum found...")
+                    if not self.verify_sha256sum_file(sha256sum_path):
+                        os.remove(sha256sum_path)
+
+                if not os.path.exists(sha256sum_path):
+                    s.download_with_progress(self.siril, sha256sum_url, sha256sum_path)
+                    if not self.verify_sha256sum_file(sha256sum_path):
+                        print("Checksum file download error, unable to proceed.")
 
                 # Check if compressed archive exists and verify checksum
                 bz2_path = os.path.join(target_dir, catfile)
@@ -819,12 +834,16 @@ class SirilCatInstallerInterface(QMainWindow):
                     bz2_url = f"https://zenodo.org/records/{SPCC_RECORD}/files/{catfile}"
                     sha256sum_url = f"{bz2_url}.sha256sum"
 
-                    # Download the .sha256sum file
                     sha256sum_path = os.path.join(target_dir, shasumfile)
-                    print(f"Downloading {sha256sum_url} to {sha256sum_path}...")
-                    response = requests.get(sha256sum_url)
-                    with open(sha256sum_path, 'wb') as f:
-                        f.write(response.content)
+                    if os.path.exists(sha256sum_path):
+                        print("Existing checksum found...")
+                        if not self.verify_sha256sum_file(sha256sum_path):
+                            os.remove(sha256sum_path)
+
+                    if not os.path.exists(sha256sum_path):
+                        s.download_with_progress(self.siril, sha256sum_url, sha256sum_path)
+                        if not self.verify_sha256sum_file(sha256sum_path):
+                            print("Checksum file download error, unable to proceed.")
 
                     # Check if compressed archive exists and verify checksum
                     bz2_path = os.path.join(target_dir, catfile)
-- 
2.52.0

Hello.

Thx for your contribution. I have one question. One return is missing?

if not self.verify_sha256sum_file(sha256sum_path):
    print("Checksum file download error, unable to proceed.")
    # Missing return????

Also; wouldn’t be more secure to check this ?

if content.startswith(('<html>', '<!DOCTYPE', '<HTML>')):

Right you are!

And actually it is a lot easier to check the well defined content of a sha256sum file instead of checking for some undefined content returned by the server.

From 7909270ad3101d183b9746a7e7044abc034a51d6 Mon Sep 17 00:00:00 2001
From: Lehel Gyuro <lehel@freemail.hu>
Date: Fri, 26 Dec 2025 19:13:58 +0100
Subject: [PATCH] Fix astrometry download issues with err 429

Download often fails due to sha256 files not containing valid sha256
signatures, but html errors returned by the server as "HTTP 200"
messages.
Moved downloader from direct requests to the siril one. Added validating
of downloaded sha256sum files. Added possibility for the user to
download the files with a different tool, place them into the dir, and
let siril validat, and unpack the contents.
---
 core/Siril_Catalog_Installer.py | 43 ++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/core/Siril_Catalog_Installer.py b/core/Siril_Catalog_Installer.py
index 70a4ef7..b1d8efa 100644
--- a/core/Siril_Catalog_Installer.py
+++ b/core/Siril_Catalog_Installer.py
@@ -34,7 +34,9 @@ import bz2
 import hashlib
 import math
 import os
+import os.path
 import platform
+import re
 import sys
 import ctypes
 import urllib.request
@@ -725,6 +727,18 @@ class SirilCatInstallerInterface(QMainWindow):
             print("Checksum verification succeeded.")
             return True
 
+    def verify_sha256sum_file(self, sha256sum_path):
+        with open(sha256sum_path, 'r', encoding='utf-8') as checksum_fp:
+            for sha256sum_content in checksum_fp:
+                sha256sum_content = sha256sum_content.strip()
+                matcher = re.compile(r"(^[0-9A-Fa-f]+)\s+(\S.*)$")
+                if not matcher.match(sha256sum_content):
+                    print(f"Verification of {sha256sum_path} failed.")
+                    return False
+
+        print(f"Verification of {sha256sum_path} succeeded.")
+        return True
+
     def install_astrometry(self):
         """Install astrometry catalog"""
         reply = QMessageBox.question(
@@ -751,10 +765,16 @@ class SirilCatInstallerInterface(QMainWindow):
             try:
                 # Download the .sha256sum file
                 sha256sum_path = os.path.join(target_dir, shasumfile)
-                print(f"Downloading {sha256sum_url} to {sha256sum_path}...")
-                response = requests.get(sha256sum_url)
-                with open(sha256sum_path, 'wb') as f:
-                    f.write(response.content)
+                if os.path.exists(sha256sum_path):
+                    print("Existing checksum found...")
+                    if not self.verify_sha256sum_file(sha256sum_path):
+                        os.remove(sha256sum_path)
+
+                if not os.path.exists(sha256sum_path):
+                    s.download_with_progress(self.siril, sha256sum_url, sha256sum_path)
+                    if not self.verify_sha256sum_file(sha256sum_path):
+                        print("Checksum file download error, unable to proceed.")
+                        return
 
                 # Check if compressed archive exists and verify checksum
                 bz2_path = os.path.join(target_dir, catfile)
@@ -819,12 +839,17 @@ class SirilCatInstallerInterface(QMainWindow):
                     bz2_url = f"https://zenodo.org/records/{SPCC_RECORD}/files/{catfile}"
                     sha256sum_url = f"{bz2_url}.sha256sum"
 
-                    # Download the .sha256sum file
                     sha256sum_path = os.path.join(target_dir, shasumfile)
-                    print(f"Downloading {sha256sum_url} to {sha256sum_path}...")
-                    response = requests.get(sha256sum_url)
-                    with open(sha256sum_path, 'wb') as f:
-                        f.write(response.content)
+                    if os.path.exists(sha256sum_path):
+                        print("Existing checksum found...")
+                        if not self.verify_sha256sum_file(sha256sum_path):
+                            os.remove(sha256sum_path)
+
+                    if not os.path.exists(sha256sum_path):
+                        s.download_with_progress(self.siril, sha256sum_url, sha256sum_path)
+                        if not self.verify_sha256sum_file(sha256sum_path):
+                            print("Checksum file download error, unable to proceed.")
+                            return
 
                     # Check if compressed archive exists and verify checksum
                     bz2_path = os.path.join(target_dir, catfile)
-- 
2.52.0