Use the ptr727.Utilities resilient HTTP client for downloads#824
Merged
Conversation
Bump ptr727.Utilities to 4.0.7 and replace the plain HttpClient with the library's resilient Download API (Polly retry + circuit breaker via Microsoft.Extensions.Http.Resilience). - Remove Program.GetHttpClient/CreateHttpClient/s_httpClient. The library's factory sets the timeout (120s default) and a user-agent from the entry assembly (PlexCleaner/<version>), matching the previous behavior, and its resilience events log through the already-wired LogOptions factory. - GitHubRelease and MkvMergeTool use Download.DownloadString; GetLatestRelease and GetLatestGitHubRelease now return a bool with an out version, updated at the four tool callers and VerifyLatestVersion. - Tools.GetUrlInfo uses Download.GetContentInfo; Tools.DownloadFile delegates to Download.DownloadFile; the manual DownloadFileAsync is removed.
There was a problem hiding this comment.
Pull request overview
This PR migrates PlexCleaner’s download/version-check HTTP usage from a manually configured HttpClient to the resilient ptr727.Utilities v4 Download API (retry/backoff + circuit breaker), affecting tool download/update flows and the app’s “latest version” check.
Changes:
- Updated tool download helpers to use
Download.GetContentInfo/Download.DownloadFile. - Updated GitHub release/version lookups to use
Download.DownloadStringand changedGetLatestRelease/GetLatestGitHubReleasetobool+out string. - Bumped
ptr727.Utilitiesfrom 3.7.5 to 4.0.7 and documented the change inHISTORY.md.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| PlexCleaner/Tools.cs | Replaced manual HTTP URL metadata lookup + file download implementation with ptr727.Utilities.Download APIs. |
| PlexCleaner/SevenZipTool.cs | Updated GitHub release lookup to bool + out version pattern. |
| PlexCleaner/Program.cs | Updated app “latest version” check to use new GitHubRelease.GetLatestRelease signature. |
| PlexCleaner/MkvMergeTool.cs | Switched latest-version JSON fetch to Download.DownloadString. |
| PlexCleaner/MediaTool.cs | Changed helper signature to GetLatestGitHubRelease(repo, out version) and delegates to GitHubRelease. |
| PlexCleaner/MediaInfoTool.cs | Updated GitHub release lookup to bool + out version pattern. |
| PlexCleaner/HandBrakeTool.cs | Updated GitHub release lookup to bool + out version pattern. |
| PlexCleaner/GitHubRelease.cs | Switched GitHub API fetch to Download.DownloadString and changed API to bool + out version. |
| PlexCleaner/FfMpegTool.cs | Updated GitHub release lookup to bool + out version pattern. |
| HISTORY.md | Added release note describing migration to resilient download client. |
| Directory.Packages.props | Bumped ptr727.Utilities package version to 4.0.7. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Switch tool downloads and the app version check from a plain
HttpClientto the resilientDownloadAPI inptr727.Utilitiesv4 — retry with exponential backoff + jitter and a circuit breaker viaMicrosoft.Extensions.Http.Resilience(Polly).Changes
ptr727.Utilities3.7.5 → 4.0.7.Program.GetHttpClient/CreateHttpClient/s_httpClient. The library's factory provides the 120 s timeout (default, matches prior) and a user-agent from the entry assembly (PlexCleaner/<version>, matches prior — so GitHub's API won't 403). Resilience/retry events log through theLogOptionsfactory already wired inProgram.cs.GitHubRelease/MkvMergeTool→Download.DownloadString.GetLatestRelease/GetLatestGitHubReleasenow returnboolwith anout version; updated the four tool version-check callers andVerifyLatestVersion.Tools.GetUrlInfo→Download.GetContentInfo(size + last-modified);Tools.DownloadFiledelegates toDownload.DownloadFile; the manualDownloadFileAsyncis removed.No functionality lost — v4's
Downloadcovers file/string/content-info, and the entry-assembly user-agent + 120 s timeout match the previous manual setup.Verification
Download.DownloadStringreaches the GitHub releases API and returns valid JSON (user-agent works, no 403). The tool-download/auto-update paths are Windows-only, so they can't be driven on the Linux dev host, but they use the same verifiedDownloadAPI.