Refactor SheepIt client download logic to always fetch the latest version, ensuring cached jars do not become stale. Improved error handling for download failures.

This commit is contained in:
Nathan
2026-05-06 00:58:12 -06:00
parent 299226f691
commit d5f1b5abb4
+15 -20
View File
@@ -57,28 +57,23 @@ try {
`$urls = $urlLiteral
`$headers = @{ 'User-Agent' = 'Mozilla/5.0' }
if (Test-Path `$jarPath) {
Write-Host "SheepIt client already present at `$jarPath. Skipping download." -ForegroundColor Green
# Always fetch client-latest; cached jars go stale when the farm bumps minimum client version.
`$downloaded = `$false
foreach (`$url in `$urls) {
Write-Host "Downloading SheepIt client from `$url..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri `$url -OutFile `$jarPath -UseBasicParsing -Headers `$headers
`$downloaded = `$true
Write-Host "Download complete -> `$jarPath" -ForegroundColor Green
break
}
catch {
Write-Host ("Download failed from {0}: {1}" -f `$url, `$_.Exception.Message) -ForegroundColor Yellow
}
}
else {
`$downloaded = `$false
foreach (`$url in `$urls) {
Write-Host "Downloading SheepIt client from `$url..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri `$url -OutFile `$jarPath -UseBasicParsing -Headers `$headers
`$downloaded = `$true
Write-Host "Download complete." -ForegroundColor Green
break
}
catch {
Write-Host ("Download failed from {0}: {1}" -f `$url, `$_.Exception.Message) -ForegroundColor Yellow
}
}
if (-not `$downloaded) {
throw 'Unable to download SheepIt client from any known URL.'
}
if (-not `$downloaded) {
throw 'Unable to download SheepIt client from any known URL.'
}
Write-Host "Starting SheepIt client..." -ForegroundColor Cyan