From 5cf1fab0fbf0fd29d684ca4bea9ca50a699cde86 Mon Sep 17 00:00:00 2001 From: "Xingjun.Wang" Date: Fri, 7 Nov 2025 16:10:22 +0800 Subject: [PATCH] Remove raise FileIntegrityError (#1517) --- modelscope/hub/utils/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modelscope/hub/utils/utils.py b/modelscope/hub/utils/utils.py index 35c562e1..d32f9ce0 100644 --- a/modelscope/hub/utils/utils.py +++ b/modelscope/hub/utils/utils.py @@ -146,16 +146,15 @@ def compute_hash(file_path): return sha256_hash.hexdigest() -def file_integrity_validation(file_path, expected_sha256): +def file_integrity_validation(file_path, expected_sha256) -> bool: """Validate the file hash is expected, if not, delete the file Args: file_path (str): The file to validate expected_sha256 (str): The expected sha256 hash - Raises: - FileIntegrityError: If file_path hash is not expected. - + Returns: + bool: True if the file is valid, False otherwise """ file_sha256 = compute_hash(file_path) if not file_sha256 == expected_sha256: @@ -163,7 +162,9 @@ def file_integrity_validation(file_path, expected_sha256): msg = 'File %s integrity check failed, expected sha256 signature is %s, actual is %s, the download may be incomplete, please try again.' % ( # noqa E501 file_path, expected_sha256, file_sha256) logger.error(msg) - raise FileIntegrityError(msg) + return False + + return True def add_content_to_file(repo,