Repository navigation
feat(fetch): {path} mirror template + FBUILD_DOWNLOAD_MIRROR_FIRST for the fbuild package mirror - #1797
Conversation
Covers `{path}` expansion for a registry download URL, its fall back to the
file name off the registry, the existing `{filename}` / bare-base forms in
configured order, the attempt order with and without
`FBUILD_DOWNLOAD_MIRROR_FIRST`, the flag's truthy parsing, a mirror-first
download that never touches the primary, and the unchanged
all-candidates-failed error naming the primary plus the mirrors tried.
Co-Authored-By: Claude Opus 5 <[email protected]>
`{path}` in an `FBUILD_DOWNLOAD_MIRRORS` entry expands to the registry-relative
path of the primary URL — everything after `/download/` on
`dl.registry.platformio.org` — so fbuild's public mirror of the PlatformIO
catalog, which preserves that layout, is reachable with one variable:
FBUILD_DOWNLOAD_MIRRORS='https://fbuild.sfo3.digitaloceanspaces.com/{path}'
Off the registry there is no such path and `{path}` degrades to the file name,
the same value `{filename}` produces. `{filename}` and bare-base entries are
untouched.
`FBUILD_DOWNLOAD_MIRROR_FIRST` (truthy: anything but unset, empty, `0`,
`false`) moves the mirrors ahead of the primary URL. The primary stays in the
list as the last resort, each candidate keeps the full retry policy, every
candidate still lands under the primary's file name, and the
all-candidates-failed error still reports the primary URL's own failure plus
the mirrors tried.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
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 |
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
Review follow-up: a mirror entry naming both `{path}` and `{filename}` had
only `{path}` substituted and shipped the literal `{filename}` in the
request URL. Substitute both; a template naming one is unchanged, because
replacing the absent placeholder is a no-op, and a bare base URL still gets
the file name appended.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
@coderabbitai review |
|
|
CodeRabbit status: auto-review is disabled on this repository, and four manual In its place I ran the repo's own Two things I deliberately did not change, for the record:
|
|
@zackees Understood. The four recorded attempts produced no CodeRabbit review, so there are no CodeRabbit findings to mark as addressed. The fix in I’ll request the current quota and reset time. I cannot schedule a review retry for later. 🧠 Learnings used
Your plan includes PR reviews subject to rate limits. More reviews will be available in 7 minutes. |
What
Teach the download mirror fallback about our own public mirror of the PlatformIO
registry catalog (DigitalOcean Spaces, bucket
fbuild, regionsfo3, public read),whose object keys preserve the registry download path after
/download/.Two additions to
crates/fbuild-packages-fetch/src/downloader_mirrors.rs:{path}template placeholder forFBUILD_DOWNLOAD_MIRRORSentries. It expandsto the registry-relative path of the primary URL — everything after
/download/ondl.registry.platformio.org. Off the registry (including a/download/segment onsome other host, e.g. a GitHub release asset) there is no such path and
{path}degrades to the last path segment, the same value
{filename}produces. So thewhole mirror is one variable:
{filename}and bare-base-URL entries are byte-identical to before;{path}ischecked first only because a template can contain just one of them.
FBUILD_DOWNLOAD_MIRROR_FIRST— truthy (anything but unset, empty,0, or acase-fold of
false) moves every configured mirror ahead of the primary URL.Unset/empty keeps today's mirrors-after-primary order.
Exact semantics
FBUILD_DOWNLOAD_MIRRORS{path}FBUILD_DOWNLOAD_MIRROR_FIRSTmirror₁ … mirrorₙ, primary; unset/empty/0/false→primary, mirror₁ … mirrorₙUnder mirror-first the primary stays in the candidate list as the last resort, so a
mirror that is missing the file (the bucket is still filling) falls through to the
vendor rather than failing the build. Unchanged in both orders: the per-candidate retry
policy, the SHA-256 check on whatever bytes arrive, the file name every candidate lands
under (always the primary's), and the final
all_candidates_failedmessage — it stillreports the primary URL's own error plus
also tried N mirror(s): …. That last partneeded the loop to track the primary's error by index instead of "first error seen",
since under mirror-first the first failure can be a mirror's.
Tests (RED → GREEN)
New in
downloader_mirror_tests.rs(no network for the pure ones; the two orderingend-to-end tests use the file's existing loopback servers):
candidate_urls_expand_path_for_a_registry_download_urlcandidate_urls_path_falls_back_to_the_file_name_off_registrycandidate_urls_keep_every_template_form_in_the_configured_orderattempt_order_tries_the_primary_first_by_defaultattempt_order_tries_mirrors_first_when_requestedmirror_first_env_follows_the_truthy_conventionmirror_first_serves_from_the_mirror_without_touching_the_primarymirror_first_still_reports_the_primary_error_when_everything_is_downRED, first commit (
fa8c859e), before any production change — the API does not exist:RED again behaviourally, with only the mirror-first half implemented (the three
{path}tests fail on the assertion, the five ordering/flag tests already pass):GREEN after the
{path}change:15 passed; 0 failedfor the mirror tests and203 passed; 0 failedfor the whole crate (soldr cargo test -p fbuild-packages-fetch).Gates run locally
soldr cargo fmt --all(clean)soldr cargo clippy -p fbuild-packages-fetch --all-targets -- -D warnings(clean)soldr cargo test -p fbuild-packages-fetch→ 203 passed, 1 ignoredRUSTDOCFLAGS="-D warnings" soldr cargo doc -p fbuild-packages-fetch --no-deps(clean)Live mirror check
{path}for…/download/platformio/platform/espressif32/6.5.0/espressif32-6.5.0.tar.gzresolves to the bucket key that serves
HTTP/2 200,content-length: 1417547,anonymously. A key the filler job has not reached yet (
platformio/tool/ framework-arduino-avr/5.4.0/…) answers403— which is exactly the case theprimary-as-last-resort ordering covers.
Notes
no error-plumbing change beyond tracking the primary's error by index.
divergent copies of the concept and no shared helper —
fbuild-cli's privateis_truthy_env(empty/0/falsefalsy),fbuild-paths' privateenv_flag_is_one(== "1"), andfbuild-daemon'srefresh_emu_cache_requested(1|true|TRUE|yes|YES).This flag follows the broadest of the three (
is_truthy_env), documented at thefunction. Unifying them is a refactor for its own PR, not this behaviour change.
🤖 Generated with Claude Code
Review follow-up (3bf3630)
A mirror entry naming both
{path}and{filename}previously had only{path}substituted and shipped the literal{filename}in the request URL.Both are now substituted; single-placeholder and bare-base entries are
unaffected (replacing an absent placeholder is a no-op), and
candidate_urls_keep_every_template_form_in_the_configured_ordergained ahttps://d.example/{path}?name={filename}case.