"""
Step 2 helper: Check available disk space on the OCR_DIR drive.
Outputs: DISK_FREE=<n>GB, DISK_STATUS=OK | LOW
"""
import os, sys, shutil
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _ocr_cfg import OCR_DIR

if not OCR_DIR:
    print("ERROR: OCR_DIR not resolved. Run preflight_workdir.py first.")
    sys.exit(1)

ocr_dir = OCR_DIR
free_gb = shutil.disk_usage(ocr_dir).free / 1024**3
print(f"DISK_FREE={round(free_gb, 1)}GB")
if free_gb < 2:
    print("DISK_STATUS=LOW")
    print("[WARN] Less than 2 GB available — download may fail")
else:
    print("DISK_STATUS=OK")
