From b0dc7295478b92faf59fc8ff2430b43f1169c9d4 Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Garcia Date: Thu, 26 Sep 2024 18:15:46 +0200 Subject: [PATCH 1/2] fix: return location after downloading --- imgsync/distros/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/imgsync/distros/base.py b/imgsync/distros/base.py index dcb0658..37ad301 100644 --- a/imgsync/distros/base.py +++ b/imgsync/distros/base.py @@ -91,6 +91,7 @@ def _download_one(self, url, checksum): location.flush() self.verify_checksum(location, url, checksum, url) + return location def verify_checksum(self, location, name, checksum, url): """Verify the image's checksum.""" From 1554a54a0adfb8a0b34c9534e402b23baa19da5d Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Garcia Date: Thu, 26 Sep 2024 18:16:00 +0200 Subject: [PATCH 2/2] feat: improve logging --- imgsync/distros/base.py | 2 ++ imgsync/distros/debian.py | 2 +- imgsync/distros/ubuntu.py | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/imgsync/distros/base.py b/imgsync/distros/base.py index 37ad301..d55ccdd 100644 --- a/imgsync/distros/base.py +++ b/imgsync/distros/base.py @@ -66,6 +66,8 @@ def _download_one(self, url, checksum): :param checksum: tuple in the form (checksum_name, checksum_value) :returns: temporary file object """ + LOG.info("Downloading %s", url) + with tempfile.NamedTemporaryFile(suffix=".imgsync", delete=False) as location: try: response = requests.get(url, stream=True, timeout=10) diff --git a/imgsync/distros/debian.py b/imgsync/distros/debian.py index dade204..566e574 100644 --- a/imgsync/distros/debian.py +++ b/imgsync/distros/debian.py @@ -78,7 +78,7 @@ def _sync_latest(self): LOG.error("Could not find checksum for %s" % filename) return - LOG.info("Downloading %s", filename) + LOG.info("Syncing %s", filename) url = base_url + filename architecture = "x86_64" diff --git a/imgsync/distros/ubuntu.py b/imgsync/distros/ubuntu.py index 428c35d..35080f5 100644 --- a/imgsync/distros/ubuntu.py +++ b/imgsync/distros/ubuntu.py @@ -56,7 +56,9 @@ def url(self): def _sync_latest(self): """Sync the latest image.""" filename = self.filename - LOG.info("Downloading %s", filename) + + LOG.info("Syncing %s", filename) + base_url = self.url + "current/" checksum_file = base_url + "SHA256SUMS" checksum_file = requests.get(checksum_file, timeout=10)