Atualizacao Pilot_Installer nao baixar se já tiver o arquivo

This commit is contained in:
2026-07-21 16:34:51 -03:00
parent 88e8bcf99a
commit dcb3eddb8e

View File

@@ -31,8 +31,6 @@ Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles() [System.Windows.Forms.Application]::EnableVisualStyles()
# ===== Configurações de versão Maio2026 ===== # ===== Configurações de versão Maio2026 =====
$VersionPortrait = "2026.05.14.1"
$VersionPortraitR = "2026.05.14.1"
$VersionDual = "2026.05.21.2" $VersionDual = "2026.05.21.2"
$VersionDualR = "2026.05.21.2" $VersionDualR = "2026.05.21.2"
$VersionBotoneira = "2026.01.13.1" $VersionBotoneira = "2026.01.13.1"
@@ -136,22 +134,42 @@ function Download-ReleaseZip {
[string]$Version [string]$Version
) )
$zipFileName = "NDGDRelease-$Version.zip" $downloadsPath = "C:\pilotgames\downloads"
$zipUrl = "$ReleaseBaseUrl/$zipFileName"
$zipDest = "C:\pilotgames\downloads\$zipFileName" if (-not (Test-Path $downloadsPath)) {
New-Item -ItemType Directory -Path $downloadsPath -Force | Out-Null
}
# Verifica primeiro se a release já existe localmente
$localFiles = @(
(Join-Path $downloadsPath "NDGDRelease-$Version.zip"),
(Join-Path $downloadsPath "BRGDRelease-$Version.zip")
)
foreach ($file in $localFiles) {
if (Test-Path $file) {
Write-Log "Release encontrada localmente:"
Write-Log $file
Write-Log "Download ignorado."
return $file
}
}
# Não encontrou localmente, determina qual arquivo baixar
if ($ReleaseBaseUrl -match "br") {
$zipFileName = "BRGDRelease-$Version.zip"
}
else {
$zipFileName = "NDGDRelease-$Version.zip"
}
$zipUrl = "$ReleaseBaseUrl/$zipFileName"
$zipDest = Join-Path $downloadsPath $zipFileName
Write-Log "Downloading release package..." Write-Log "Downloading release package..."
Write-Log "URL: $zipUrl" Write-Log "URL: $zipUrl"
try { try {
if (-not (Test-Path "C:\pilotgames\downloads")) {
New-Item -ItemType Directory -Path "C:\pilotgames\downloads" -Force | Out-Null
}
if (Test-Path $zipDest) {
Remove-Item -Path $zipDest -Force -ErrorAction SilentlyContinue
}
Invoke-WebRequest -Uri $zipUrl -OutFile $zipDest -UseBasicParsing Invoke-WebRequest -Uri $zipUrl -OutFile $zipDest -UseBasicParsing
Write-Log "Download completed: $zipDest" Write-Log "Download completed: $zipDest"
return $zipDest return $zipDest