mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-09 15:38:43 +00:00
Handle download failure in installers
This commit is contained in:
36
install.ps1
36
install.ps1
@@ -23,6 +23,32 @@ if ($choco) {
|
||||
foreach ($p in $packages) { Install-Pkg $p }
|
||||
}
|
||||
|
||||
function Install-PipFallback {
|
||||
if (Get-Command pip -ErrorAction SilentlyContinue) {
|
||||
try {
|
||||
pip install --user voxvera
|
||||
Write-Host 'VoxVera installed successfully via pip.'
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error 'pip installation failed.'
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Error 'pip not found for fallback installation.'
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Download-Binary {
|
||||
param([string]$Url, [string]$Dest)
|
||||
try {
|
||||
Invoke-WebRequest -Uri $Url -OutFile $Dest -ErrorAction Stop
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
||||
try {
|
||||
pipx install voxvera --force
|
||||
@@ -31,13 +57,19 @@ if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
||||
$dest = "$HOME/.local/bin"
|
||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
||||
Invoke-WebRequest -Uri $url -OutFile "$dest/voxvera.exe"
|
||||
if (-not (Download-Binary $url "$dest/voxvera.exe")) {
|
||||
Write-Host 'Binary download failed, falling back to pip'
|
||||
Install-PipFallback
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dest = "$HOME/.local/bin"
|
||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
||||
Invoke-WebRequest -Uri $url -OutFile "$dest/voxvera.exe"
|
||||
if (-not (Download-Binary $url "$dest/voxvera.exe")) {
|
||||
Write-Host 'Binary download failed, falling back to pip'
|
||||
Install-PipFallback
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host 'VoxVera installed successfully.'
|
||||
|
Reference in New Issue
Block a user