Improve self-update package downloads#348
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds range-probing and multipart-download support to the Windows self-update bootstrap, stages downloads in a per-update package cache with safe temp-file semantics, simplifies package decompression to a stream, and adds tests that build and validate Zstd-compressed tar packages and HTTP range behaviors. ChangesMultipart Download and Self-Update Refactor
Sequence Diagram(s)sequenceDiagram
participant SelfUpdateBootstrap
participant RemoteServer
participant Disk
SelfUpdateBootstrap->>RemoteServer: GET Range: bytes=0-0 (probe)
RemoteServer-->>SelfUpdateBootstrap: 206 + Content-Range / Content-Length or no-range support
alt Server supports ranges AND file > threshold
SelfUpdateBootstrap->>SelfUpdateBootstrap: Compute download ranges
loop For each part (parallel)
SelfUpdateBootstrap->>RemoteServer: GET Range: bytes=start-end
RemoteServer-->>SelfUpdateBootstrap: 206 Partial Content
SelfUpdateBootstrap->>Disk: Write part file
end
SelfUpdateBootstrap->>Disk: Merge part files into ".partial"
SelfUpdateBootstrap->>Disk: Delete part files
else Single download
SelfUpdateBootstrap->>RemoteServer: GET full file
RemoteServer-->>SelfUpdateBootstrap: 200 OK Full content
SelfUpdateBootstrap->>Disk: Write to ".partial"
end
SelfUpdateBootstrap->>Disk: Verify total length
SelfUpdateBootstrap->>Disk: Move ".partial" to final cache path
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
TelegramSearchBot.Test/Service/Update/SelfUpdateBootstrapTests.cs (1)
715-747: ⚡ Quick winCover the fallback path, not just the happy-path merge.
This test proves multipart merge works, but it never exercises the new
ProbeDownloadAsync/DownloadFileFromUriAsyncbranch that should fall back to single-stream when ranges are unsupported or a part response is invalid. Since fallback is a core behavior of this PR, add one handler variant that returns200 OKto the probe or a bad range response and assert the final file still downloads correctly.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@TelegramSearchBot.Test/Service/Update/SelfUpdateBootstrapTests.cs` around lines 715 - 747, Add a negative-path variant of the existing test that forces the fallback branch in DownloadFileInPartsAsync (which calls ProbeDownloadAsync and may call DownloadFileFromUriAsync) by using an HTTP handler that either returns 200 OK for the probe request (no Range header) or returns an invalid/bad response for range requests; invoke the same private static helper as in DownloadFileInPartsAsync_RequestsRangesAndMergesFile to run the download, then assert the resulting file contents match the payload and that the handler recorded that the multipart range flow was not used (e.g., RangeRequests count is 0 or only a single full-file request was made) to prove the fallback single-stream download path is executed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@TelegramSearchBot/Service/Update/SelfUpdateBootstrap.Windows.cs`:
- Around line 415-417: The 206 handling in the DownloadProbe path currently
trusts any PartialContent with a matching Length; change it to validate
response.Content.Headers.ContentRange so ContentRange.From and ContentRange.To
exactly equal the requested byte range (and ContentRange.Length equals
rangeLength) before returning new DownloadProbe(true, rangeLength); otherwise
treat it as a bad range (reject range mode/fall back). Apply the same strict
Content-Range From/To validation in the per-part code path (the similar 206
handling around the 512-521 region) so both DownloadProbe and per-part downloads
only accept responses whose ContentRange.From/To exactly match the requested
start/end.
---
Nitpick comments:
In `@TelegramSearchBot.Test/Service/Update/SelfUpdateBootstrapTests.cs`:
- Around line 715-747: Add a negative-path variant of the existing test that
forces the fallback branch in DownloadFileInPartsAsync (which calls
ProbeDownloadAsync and may call DownloadFileFromUriAsync) by using an HTTP
handler that either returns 200 OK for the probe request (no Range header) or
returns an invalid/bad response for range requests; invoke the same private
static helper as in DownloadFileInPartsAsync_RequestsRangesAndMergesFile to run
the download, then assert the resulting file contents match the payload and that
the handler recorded that the multipart range flow was not used (e.g.,
RangeRequests count is 0 or only a single full-file request was made) to prove
the fallback single-stream download path is executed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fa7ed685-f350-4873-8a6c-ab695a9fa604
📒 Files selected for processing (2)
TelegramSearchBot.Test/Service/Update/SelfUpdateBootstrapTests.csTelegramSearchBot/Service/Update/SelfUpdateBootstrap.Windows.cs
PR Check ReportSummary
Test Results
Code Quality
Test Artifacts
LinksThis report is auto-generated by GitHub Actions |
Summary
Validation
Summary by CodeRabbit
New Features
Tests