From d5f1b5abb475e34f8305a0dc25a148a1e5c5551a Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 6 May 2026 00:58:12 -0600 Subject: [PATCH] Refactor SheepIt client download logic to always fetch the latest version, ensuring cached jars do not become stale. Improved error handling for download failures. --- unified_sheepit_launcher.ps1 | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/unified_sheepit_launcher.ps1 b/unified_sheepit_launcher.ps1 index 990aed2..f6e8bdf 100644 --- a/unified_sheepit_launcher.ps1 +++ b/unified_sheepit_launcher.ps1 @@ -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