Skip to content

Commit 5eed052

Browse files
committed
fix: move checksum verification into a separate function
Fixes #1
1 parent c016597 commit 5eed052

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

imgsync/distros/base.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ def _get_file_checksum(self, path, block_size=2**20):
5757
buf = f.read(block_size)
5858
return sha512
5959

60-
def verify_checksum(
61-
self,
62-
location,
63-
name,
64-
checksum,
65-
):
66-
"""Verify the image's checksum."""
67-
# TODO(aloga): not implemented yet
68-
6960
def _download_one(self, url, checksum):
7061
"""Download a file.
7162
@@ -99,6 +90,17 @@ def _download_one(self, url, checksum):
9990
location.write(block)
10091
location.flush()
10192

93+
self.verify_checksum(location, url, checksum, url)
94+
95+
def verify_checksum(
96+
self,
97+
location,
98+
name,
99+
checksum,
100+
url
101+
):
102+
"""Verify the image's checksum."""
103+
102104
checksum_map = {"sha512": hashlib.sha512, "sha256": hashlib.sha256}
103105
sha = checksum_map.get(checksum[0])()
104106
block_size = 2**20

0 commit comments

Comments
 (0)