Compare commits

...

3 Commits

Author SHA1 Message Date
Martin Tranberg
9e40abcfd8 Robust type-konvertering af konfigurations-værdier
- Implementerer korrekt boolean parsing for ENABLE_HASH_VALIDATION
- Tilføjer fejlhåndtering (try/except) ved parsing af HASH_THRESHOLD_MB
- Sikrer 100% konsistens mellem GUI-input og backend-logik
2026-03-29 19:58:45 +02:00
Martin Tranberg
03a766be63 Opdatér template med nye hash-variabler
- Tilføjer ENABLE_HASH_VALIDATION og HASH_THRESHOLD_MB til connection_info.template.txt
2026-03-29 19:56:07 +02:00
Martin Tranberg
1a97ca3d53 Cleanup og variabel-synkronisering
- Rydder op i duplicate kode i download_single_file
- Sikrer korrekt type-casting af config-variabler (bool/int)
- Verificerer at alle GUI-parametre læses korrekt i main()
2026-03-29 19:55:08 +02:00
2 changed files with 9 additions and 12 deletions

View File

@@ -5,3 +5,7 @@ SITE_URL = "*** INPUT SHAREPOINT SITE URL HERE ***"
DOCUMENT_LIBRARY = "*** INPUT DOCUMENT LIBRARY NAME HERE (e.g. Documents) ***"
FOLDERS_TO_DOWNLOAD = "*** INPUT FOLDERS TO DOWNLOAD (Comma separated). LEAVE EMPTY TO DOWNLOAD ENTIRE LIBRARY ***"
LOCAL_PATH = "*** INPUT LOCAL DESTINATION PATH HERE ***"
# Hash Validation Settings
ENABLE_HASH_VALIDATION = "True"
HASH_THRESHOLD_MB = "30"

View File

@@ -306,17 +306,6 @@ def download_single_file(app, drive_id, item_id, local_path, expected_size, disp
else:
return False, f"Size mismatch: Remote={expected_size}, Local={final_size}"
except Exception as e:
return False, str(e)
if final_size == expected_size:
if verify_integrity(local_path, remote_hash):
logger.info(f"DONE: {display_name}")
return True, None
else:
return False, "Integrity check failed (Hash mismatch)"
else:
return False, f"Size mismatch: Remote={expected_size}, Local={final_size}"
except Exception as e:
return False, str(e)
@@ -388,9 +377,13 @@ def main():
# Opdater globale indstillinger fra config hvis de findes
global ENABLE_HASH_VALIDATION, HASH_THRESHOLD_MB
if 'ENABLE_HASH_VALIDATION' in config:
# Vi tjekker om strengen er 'true' (case-insensitive)
ENABLE_HASH_VALIDATION = config['ENABLE_HASH_VALIDATION'].lower() == 'true'
if 'HASH_THRESHOLD_MB' in config:
HASH_THRESHOLD_MB = int(config['HASH_THRESHOLD_MB'])
try:
HASH_THRESHOLD_MB = int(config['HASH_THRESHOLD_MB'])
except ValueError:
logger.warning(f"Ugyldig værdi for HASH_THRESHOLD_MB i config: {config['HASH_THRESHOLD_MB']}. Bruger standard: {HASH_THRESHOLD_MB}")
folders = [f.strip() for f in folders_str.split(',') if f.strip()] or [""]