This commit is contained in:
fourbroad
2026-07-05 13:45:03 +08:00
parent e79718a5fb
commit e3098f2225
+11 -5
View File
@@ -96,13 +96,16 @@ function Install-Octopus {
try {
$null = Invoke-WebRequest -Uri $releaseUrl -Method Head -UseBasicParsing -ErrorAction Stop
} catch {
throw "Release v$specificVersion not found. Available releases: $baseUrl/$REPO/releases"
Write-Color "Error: Release v$specificVersion not found." "Red"
Write-Color "Available releases: $baseUrl/$REPO/releases" "DarkGray"
exit 1
}
} else {
Write-Color "Fetching latest version..." "DarkGray"
$specificVersion = Get-LatestVersion
if (-not $specificVersion) {
throw "Failed to fetch latest version."
Write-Color "Error: Failed to fetch latest version." "Red"
exit 1
}
}
@@ -113,7 +116,7 @@ function Install-Octopus {
$installedVersion = & $existing --version 2>$null
if ($installedVersion -eq $specificVersion) {
Write-Color "Version $specificVersion already installed." "DarkGray"
return
exit 0
} else {
Write-Color "Installed version: $installedVersion" "DarkGray"
}
@@ -141,8 +144,10 @@ function Install-Octopus {
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing
} catch {
Write-Color "Error: Failed to download $downloadUrl" "Red"
Write-Color $_.Exception.Message "Red"
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
throw "Failed to download $downloadUrl : $($_.Exception.Message)"
exit 1
}
# Extract
@@ -152,8 +157,9 @@ function Install-Octopus {
New-Item -ItemType Directory -Path $INSTALL_DIR -Force | Out-Null
$exeSrc = Join-Path $tmpDir "$APP.exe"
if (-not (Test-Path $exeSrc)) {
Write-Color "Error: $APP.exe not found in archive." "Red"
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
throw "$APP.exe not found in archive."
exit 1
}
Copy-Item -Path $exeSrc -Destination (Join-Path $INSTALL_DIR "$APP.exe") -Force
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue