diff --git a/download_sharepoint.py b/download_sharepoint.py index 05e3012..ca2c3ba 100644 --- a/download_sharepoint.py +++ b/download_sharepoint.py @@ -18,6 +18,10 @@ CHUNK_SIZE = 1024 * 1024 # 1MB Chunks MAX_FOLDER_DEPTH = 50 LOG_FILE = "sharepoint_download.log" +# Hash Validation Settings +ENABLE_HASH_VALIDATION = True # Set to False to only check file size +HASH_THRESHOLD_MB = 30 # Only hash files smaller than this (in MB) + # Setup Logging logging.basicConfig( level=logging.INFO, @@ -106,18 +110,16 @@ 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. - Skips hash check for files larger than HASH_THRESHOLD_BYTES to save time.""" - if not remote_hash: + """Verifies file integrity based on global settings.""" + if not remote_hash or not ENABLE_HASH_VALIDATION: 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)})") + threshold_bytes = HASH_THRESHOLD_MB * 1024 * 1024 + + if file_size > threshold_bytes: + logger.info(f"Skipping hash check (size > {HASH_THRESHOLD_MB}MB): {os.path.basename(local_path)}") return True local_hash = quickxorhash(local_path)