# Verify CRLF preservation after sync fix

Write-Host "[INFO] Verifying CRLF on files from NAS..."
Write-Host ""

# Copy fresh from NAS using -O flag (binary mode)
Write-Host "[INFO] Copying DEPLOY.BAT from NAS..."
& 'C:\Windows\System32\OpenSSH\scp.exe' -O root@192.168.0.9:/data/test/DEPLOY.BAT ./DEPLOY_VERIFY.BAT 2>$null

if (Test-Path "DEPLOY_VERIFY.BAT") {
    $Content = Get-Content "DEPLOY_VERIFY.BAT" -Raw
    $Size = (Get-Item "DEPLOY_VERIFY.BAT").Length

    Write-Host "[INFO] File size: $Size bytes"

    if ($Content -match "`r`n") {
        Write-Host "[SUCCESS] CRLF preserved on NAS!"
    } else {
        Write-Host "[ERROR] Still LF only - sync may not have run yet"
    }

    # Compare with original
    $OrigSize = (Get-Item "DEPLOY.BAT").Length
    Write-Host "[INFO] Original size: $OrigSize bytes"

    if ($Size -eq $OrigSize) {
        Write-Host "[OK] Sizes match - line endings preserved"
    } else {
        Write-Host "[WARNING] Size mismatch - may need another sync cycle"
    }
} else {
    Write-Host "[ERROR] Failed to copy from NAS"
}

Write-Host ""
Write-Host "[INFO] Note: If still LF only, wait for next sync cycle (every 15 min)"
