From 33fbdc244de241485425e5336143d16e146ad651 Mon Sep 17 00:00:00 2001 From: Martin Tranberg Date: Sun, 29 Mar 2026 17:40:55 +0200 Subject: [PATCH] =?UTF-8?q?Tilf=C3=B8j=2030=20MB=20gr=C3=A6nse=20for=20has?= =?UTF-8?q?h-validering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Spring hash-tjek over for filer over 30 MB for at spare tid ved store filer (f.eks. 65 GB) - Filer over grænsen sammenlignes kun på størrelse - Tilføjer logning når hash-tjek springes over --- download_sharepoint.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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}")