Skip to content

Commit

Permalink
fix(download): Fallback to default downloader when aria2 fails (#4292)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiennq authored Aug 26, 2024
1 parent 79cf33d commit e0c682d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Bug Fixes

- **scoop-download|install|update:** Fallback to default downloader when aria2 fails ([#4292](https://github.com/ScoopInstaller/Scoop/issues/4292))
- **decompress**: `Expand-7zipArchive` only delete temp dir / `$extractDir` if it is empty ([#6092](https://github.com/ScoopInstaller/Scoop/issues/6092))

### Code Refactoring
Expand Down
21 changes: 16 additions & 5 deletions lib/download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function Invoke-Download ($url, $to, $cookies, $progress) {
# Handle manual file rename
if ($url -like '*#/*') {
$null, $postfix = $url -split '#/'
$newUrl = "$newUrl#/$postfix"
$newUrl = "$newUrl`#/$postfix"
}

Invoke-Download $newUrl $to $cookies $progress
Expand Down Expand Up @@ -454,10 +454,21 @@ function Invoke-CachedAria2Download ($app, $version, $manifest, $architecture, $
Write-Host ''

if ($lastexitcode -gt 0) {
error "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
error $urlstxt_content
error $aria2
abort $(new_issue_msg $app $bucket 'download via aria2 failed')
warn "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
warn $urlstxt_content
warn $aria2
warn $(new_issue_msg $app $bucket "download via aria2 failed")

Write-Host "Fallback to default downloader ..."

try {
foreach ($url in $urls) {
Invoke-CachedDownload $app $version $url "$($data.$url.target)" $cookies $use_cache
}
} catch {
Write-Host $_ -ForegroundColor DarkRed
abort "URL $url is not valid"
}
}

# remove aria2 input file when done
Expand Down

0 comments on commit e0c682d

Please sign in to comment.