diff --git a/download_sharepoint.py b/download_sharepoint.py index e3ce989..05e3012 100644 --- a/download_sharepoint.py +++ b/download_sharepoint.py @@ -106,10 +106,20 @@ def quickxorhash(file_path): result = h.to_bytes(20, byteorder='little') return base64.b64encode(result).decode('ascii') +# --- Integrity Thresholds --- +HASH_THRESHOLD_BYTES = 30 * 1024 * 1024 # 30 MB + def verify_integrity(local_path, remote_hash): - """Verifies file integrity using Microsoft QuickXorHash.""" + """Verifies file integrity using Microsoft QuickXorHash. + Skips hash check for files larger than HASH_THRESHOLD_BYTES to save time.""" if not remote_hash: - return True # Intet hash fra remote; fald tilbage til størrelses-check + return True + + file_size = os.path.getsize(local_path) + if file_size > HASH_THRESHOLD_BYTES: + logger.info(f"Skipping hash check for large file (>30MB): {os.path.basename(local_path)} ({format_size(file_size)})") + return True + local_hash = quickxorhash(local_path) if local_hash != remote_hash: logger.warning(f"Hash mismatch for {local_path}: local={local_hash}, remote={remote_hash}")