Skip to content

Commit 0e155e2

Browse files
committed
tried to improve error handling and rollback functionality.
1 parent 01ffd0c commit 0e155e2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modpack_win.ps1

+5-4
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ function download($array) {
5252
for($i=0;$i -lt $array.length;$i++){
5353
if ($status){$errorcount = 0}
5454
Write-Output "[$($i+1) of $($array.length)]: $($array[$i][1])"
55-
Invoke-WebRequest -Uri $array[$i][0] -OutFile $array[$i][1] -ErrorVariable +err
56-
if (-not $?) {
55+
Invoke-WebRequest -Uri $array[$i][0] -OutFile $array[$i][1] -ErrorVariable +err
56+
if (-not $?) {
5757
$status = $?
58-
$i = $i - 1
5958
$errorcount = $errorcount + 1
6059
if ($errorcount -lt 3){
6160
Write-Output "Failed to download $($array[$i][1]). Trying again.`r`n"
6261
}else{
6362
Write-Output "Failed to download $($array[$i][1]) three (3) consecutive times. `r`n`r`nPlease make sure you have an internet connection and the newest version`r`nof the KSPtoMars mod installer. `r`nThe error message was: `r`n`r`n$($err[$($err.lenght - 1)])"
64-
rollback($BackupPath)
63+
rollback($BackupPath)
6564
}
65+
$i = $i - 1
6666
}
6767
}
6868
}
@@ -71,6 +71,7 @@ function download($array) {
7171
function rollback($RPATH){
7272
Remove-Item -Recurse -Force $gameDataPath
7373
new-item -itemtype directory $gameDataPath > $null
74+
new-item -itemtype directory $gameDataPath/Squad > $null
7475
Move-Item -Recurse $RPATH $gameDataPath/Squad
7576
exit
7677
}

0 commit comments

Comments
 (0)