diff options
author | Hind-M <hind.montassif@gmail.com> | 2021-06-04 16:39:16 +0200 |
---|---|---|
committer | Hind-M <hind.montassif@gmail.com> | 2021-06-04 16:39:16 +0200 |
commit | 16867ca9321e50531307253e957b91c4df7e564c (patch) | |
tree | 0d1953844d6a9e6ba609154b00568e2baadef660 /src/python/gudhi/datasets/remote.py | |
parent | f7b4d9f3ed0b0c386204077ea53a22e2dba527fc (diff) |
Verify checksum even for already existing files locally
Diffstat (limited to 'src/python/gudhi/datasets/remote.py')
-rw-r--r-- | src/python/gudhi/datasets/remote.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py index b266467d..aef4b277 100644 --- a/src/python/gudhi/datasets/remote.py +++ b/src/python/gudhi/datasets/remote.py @@ -63,7 +63,7 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): file_path = join(dirname, filename) - # Check that an existing file does not already exist at file_path + # Check for an already existing file at file_path if not exists(file_path): # Create directory if not existing if not exists(dirname): @@ -71,13 +71,12 @@ def fetch(url, filename, dirname = "remote_datasets", file_checksum = None): urlretrieve(url, file_path) - if file_checksum is not None: - checksum = _checksum_sha256(file_path) - if file_checksum != checksum: - raise IOError("{} has a SHA256 checksum : {}, " - "different from expected : {}." - "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, - file_checksum)) + if file_checksum is not None: + checksum = _checksum_sha256(file_path) + if file_checksum != checksum: + raise IOError("{} has a SHA256 checksum : {}, " + "different from expected : {}." + "The file may be corrupted or the given url may be wrong !".format(file_path, checksum, file_checksum)) return file_path |