fix update script thing

This commit is contained in:
IsWaffle 2024-05-04 17:57:59 -04:00
parent ec3bf67995
commit a4131fe276

View File

@ -15,13 +15,48 @@ if ($installer -ne $null)
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 ..."
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-Item -Path $source