Skip to content

Commit e0c682d

Browse files
authored
fix(download): Fallback to default downloader when aria2 fails (#4292)
1 parent 79cf33d commit e0c682d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Bug Fixes
44

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

78
### Code Refactoring

lib/download.ps1

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function Invoke-Download ($url, $to, $cookies, $progress) {
138138
# Handle manual file rename
139139
if ($url -like '*#/*') {
140140
$null, $postfix = $url -split '#/'
141-
$newUrl = "$newUrl#/$postfix"
141+
$newUrl = "$newUrl`#/$postfix"
142142
}
143143

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

456456
if ($lastexitcode -gt 0) {
457-
error "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
458-
error $urlstxt_content
459-
error $aria2
460-
abort $(new_issue_msg $app $bucket 'download via aria2 failed')
457+
warn "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
458+
warn $urlstxt_content
459+
warn $aria2
460+
warn $(new_issue_msg $app $bucket "download via aria2 failed")
461+
462+
Write-Host "Fallback to default downloader ..."
463+
464+
try {
465+
foreach ($url in $urls) {
466+
Invoke-CachedDownload $app $version $url "$($data.$url.target)" $cookies $use_cache
467+
}
468+
} catch {
469+
Write-Host $_ -ForegroundColor DarkRed
470+
abort "URL $url is not valid"
471+
}
461472
}
462473

463474
# remove aria2 input file when done

0 commit comments

Comments
 (0)