Merge pull request 'fix update script thing' (#81) from waffle.lord/SPT-AKI-Installer:fix/update-script into master

Reviewed-on: CWX/SPT-AKI-Installer#81
This commit is contained in:
IsWaffle 2024-05-04 21:59:36 +00:00
commit 2bd28f0796

View File

@ -15,13 +15,48 @@ if ($installer -ne $null)
return; return;
} }
if (-not(Test-Path $source) -and -not(Test-Path $destination)) {
Write-Warning "Can't find a required file"
Write-host ""
Write-Host "Press [enter] to close ..."
Read-Host
exit
}
Write-Host "Copying new installer ..." Write-Host "Copying new installer ..."
Import-Module BitsTransfer $maxAttempts = 10
$copied = $false
Start-BitsTransfer -Source $source -Destination $destination while (-not $copied) {
Remove-Module BitsTransfer $maxAttempts--
Write-Host "Please wait ..."
if ($maxAttempts -le 0) {
Write-Host "Couldn't copy new installer :( Please re-download the installer"
Write-Host ""
Write-Host "Press [enter] to close ..."
Read-Host
exit
}
Remove-Item $destination -ErrorAction SilentlyContinue
Copy-Item $source $destination
if (Test-Path $destination) {
$sLength = (Get-Item $source).Length
$dLength = (Get-Item $destination).Length
if ($sLength -eq $dLength) {
$copied = $true
break
}
sleep(2)
}
}
# remove the new installer from the cache folder after it is copied # remove the new installer from the cache folder after it is copied
Remove-Item -Path $source Remove-Item -Path $source