Skip to content

Conversation

@z-Fng
Copy link
Member

@z-Fng z-Fng commented Nov 4, 2025

Description

This PR makes the following changes:

  • feat(download|scoop-config): Introduce option aria2-fallback-disabled to allow disabling automatic fallback to the default downloader when Aria2c download fails.

Related PRs/Issues

How Has This Been Tested?

image

Checklist

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

Summary by CodeRabbit

  • New Features

    • Added an aria2-fallback-disabled setting to let users disable automatic fallback to the default downloader when aria2 fails; when enabled, failures emit an error and abort the download.
  • Bug Fixes

    • Skip the GitHub issue prompt when the downloader falls back to the default.

@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

Walkthrough

Adds a new configuration option aria2-fallback-disabled and updates download logic so that when aria2 exits non‑zero and the option is enabled, the process logs error details and aborts instead of falling back to the default downloader. Changelog updated.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Adds entry documenting new `download
Configuration
libexec/scoop-config.ps1
Adds aria2-fallback-disabled configuration option (`$true
Download logic
lib/download.ps1
When aria2 finishes with a non-zero exit code, checks ARIA2-FALLBACK-DISABLED; if set, emits error messages (exit code, aria_exit_code, urlstxt_content and aria2 output) and aborts with a generated issue message; otherwise preserves existing fallback flow. Public API not changed.

Sequence Diagram

sequenceDiagram
    participant User
    participant Download as lib/download.ps1
    participant Aria2 as aria2c
    participant DefaultDL as Default Downloader

    User->>Download: start download
    Download->>Aria2: run aria2c
    Aria2-->>Download: exit (non-zero)

    alt aria2-fallback-disabled = true
        Download->>Download: log exit code, aria output, urlstxt_content
        Download-->>User: abort with generated issue message
    else aria2-fallback-disabled = false
        Download->>Download: log fallback decision
        Download->>DefaultDL: invoke default downloader
        DefaultDL-->>Download: download result
        Download-->>User: complete (success/failure)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review lib/download.ps1 conditional handling of ARIA2-FALLBACK-DISABLED, error logging content, and abort path.
  • Verify libexec/scoop-config.ps1 documentation text and option naming/format.
  • Confirm CHANGELOG.md entry accurately describes behavior.

Poem

🐰 A rabbit cheers, the flag set true,
No secret fallback to chase askew,
Aria2 speaks, if it fails we see,
Logs and a halt — tidy as can be.
Hops and a nibble, configuration anew.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately summarizes the main change: introducing a configuration option to disable automatic fallback to the default downloader when Aria2c download fails, which is reflected in all three modified files (CHANGELOG.md, lib/download.ps1, and libexec/scoop-config.ps1).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@niheaven
Copy link
Member

niheaven commented Nov 7, 2025

Please add only one chglog item.

@z-Fng z-Fng force-pushed the add-aria2-fallback-disabled-option branch from d0d751c to ee1882c Compare November 7, 2025 12:05
@z-Fng
Copy link
Member Author

z-Fng commented Nov 7, 2025

Please add only one chglog item.

Done.

fix(download): Skip GitHub issue prompt when falling back to the default downloader

This change will be moved to #6539.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/download.ps1 (1)

457-479: Consider restructuring with an else block for clarity.

While the current implementation works correctly (since abort terminates execution), wrapping lines 464-479 in an else block would make the mutually exclusive control flow more explicit and improve maintainability.

             if (get_config 'aria2-fallback-disabled') {
                 error "Download failed! (Error $lastexitcode) $(aria_exit_code $lastexitcode)"
                 error $urlstxt_content
                 error $aria2
                 abort $(new_issue_msg $app $bucket 'download via aria2 failed')
+            } else {
+                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"
+                }
             }
-
-            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"
-            }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0d751c and ee1882c.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • lib/download.ps1 (1 hunks)
  • libexec/scoop-config.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libexec/scoop-config.ps1
  • CHANGELOG.md
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-31T01:35:53.228Z
Learnt from: z-Fng
Repo: ScoopInstaller/Scoop PR: 6473
File: libexec/scoop-download.ps1:105-109
Timestamp: 2025-08-31T01:35:53.228Z
Learning: In the Scoop codebase, `Invoke-CachedAria2Download` calls `abort` on failure, which terminates the entire script execution rather than throwing catchable exceptions. Therefore, try-catch blocks around this function are not useful for error handling.

Applied to files:

  • lib/download.ps1
📚 Learning: 2025-08-31T01:39:35.684Z
Learnt from: z-Fng
Repo: ScoopInstaller/Scoop PR: 6473
File: libexec/scoop-download.ps1:135-135
Timestamp: 2025-08-31T01:39:35.684Z
Learning: In the Scoop codebase, `Invoke-ScoopDownload` in lib/download.ps1 calls `abort` when hash verification fails, which terminates script execution completely rather than trying remaining mirrors. The scoop-download.ps1 script should maintain consistency with this behavior by using `continue app_loop` to skip to the next app rather than trying remaining mirrors for the current app.

Applied to files:

  • lib/download.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PowerShell

@z-Fng z-Fng changed the title feat(download|scoop-config): Allow disabling automatic fallback to the default downloader feat(download|scoop-config): Allow disabling automatic fallback to the default downloader when Aria2c download fails Nov 7, 2025
@z-Fng z-Fng changed the title feat(download|scoop-config): Allow disabling automatic fallback to the default downloader when Aria2c download fails feat(download|scoop-config): Allow disabling automatic fallback to the default downloader Nov 7, 2025
@niheaven niheaven merged commit 28c51e0 into ScoopInstaller:develop Nov 8, 2025
3 checks passed
@z-Fng z-Fng deleted the add-aria2-fallback-disabled-option branch November 8, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants