diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py index 4cace27090..d2f7b9d7fe 100644 --- a/easybuild/tools/filetools.py +++ b/easybuild/tools/filetools.py @@ -1305,6 +1305,9 @@ def verify_checksum(path, checksums, computed_checksums=None): checksum = checksum[filename] except KeyError: raise EasyBuildError("Missing checksum for %s in %s", filename, checksum) + if not verify_checksum(path, checksum, computed_checksums): + return False + continue if isinstance(checksum, str): # if no checksum type is specified, it is assumed to be MD5 (32 characters) or SHA256 (64 characters) diff --git a/test/framework/filetools.py b/test/framework/filetools.py index e59c3099f1..edf3a942c2 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -356,6 +356,8 @@ def test_checksums(self): # Check dictionary alt_checksums = (known_checksums['sha256'],) self.assertTrue(ft.verify_checksum(fp, {os.path.basename(fp): known_checksums['sha256']})) + # None is accepted + self.assertTrue(ft.verify_checksum(fp, {os.path.basename(fp): None})) faulty_dict = {'wrong-name': known_checksums['sha256']} self.assertErrorRegex(EasyBuildError, "Missing checksum for " + os.path.basename(fp) + " in .*wrong-name.*", @@ -371,6 +373,8 @@ def test_checksums(self): self.assertTrue(ft.verify_checksum(fp, known_checksums['sha256'])) # Test dictionary-type checksums + self.assertErrorRegex(EasyBuildError, "Missing checksum for", ft.verify_checksum, + fp, {os.path.basename(fp): None}) for checksum in [known_checksums[x] for x in ['sha256']]: dict_checksum = {os.path.basename(fp): checksum, 'foo': 'baa'} self.assertTrue(ft.verify_checksum(fp, dict_checksum))