diff --git a/imgsync/distros/base.py b/imgsync/distros/base.py index 4b81b20..2e2039e 100644 --- a/imgsync/distros/base.py +++ b/imgsync/distros/base.py @@ -57,15 +57,6 @@ def _get_file_checksum(self, path, block_size=2**20): buf = f.read(block_size) return sha512 - def verify_checksum( - self, - location, - name, - checksum, - ): - """Verify the image's checksum.""" - # TODO(aloga): not implemented yet - def _download_one(self, url, checksum): """Download a file. @@ -99,6 +90,17 @@ def _download_one(self, url, checksum): location.write(block) location.flush() + self.verify_checksum(location, url, checksum, url) + + def verify_checksum( + self, + location, + name, + checksum, + url + ): + """Verify the image's checksum.""" + checksum_map = {"sha512": hashlib.sha512, "sha256": hashlib.sha256} sha = checksum_map.get(checksum[0])() block_size = 2**20