mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
feat: verify downloads in powershell installer
This commit is contained in:
1 parent
587aadde08
commit
86229a84cd
1 file changed
+23
-3
+23
-3
@@ -89,12 +89,32 @@ foreach ($f in $toDownload) {
|
||||
$url = "$baseUrl/$($f.repo_path)"
|
||||
}
|
||||
|
||||
try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing
|
||||
$tmp = "$dest.tmp"
|
||||
$ok = $false
|
||||
foreach ($attempt in 1..3) {
|
||||
try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $tmp -UseBasicParsing
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
if ($f.sha1) {
|
||||
$actual = (Get-FileHash $tmp -Algorithm SHA1).Hash.ToLower()
|
||||
if ($actual -ne $f.sha1) {
|
||||
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
|
||||
continue
|
||||
}
|
||||
}
|
||||
Move-Item $tmp $dest -Force
|
||||
$ok = $true
|
||||
break
|
||||
}
|
||||
|
||||
if ($ok) {
|
||||
$downloaded++
|
||||
$i = $downloaded + $errors
|
||||
Write-Host " [$i/$total] $($f.dest) ok"
|
||||
} catch {
|
||||
} else {
|
||||
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
|
||||
$errors++
|
||||
$i = $downloaded + $errors
|
||||
Write-Host " [$i/$total] $($f.dest) FAILED" -ForegroundColor Red
|
||||
|
||||
Reference in new issue
Block a user