Template a registry's dl field#4836
Merged
bors merged 3 commits intorust-lang:masterfrom Dec 19, 2017
Merged
Conversation
Previously, crate files were always downloaded from
`/{crate}/{version}/download`. However, if the backing crate store for a
custom registry is a raw file server rather than an API endpoint that
requires every file to be named `download` which is a bit weird. Now a
registry's dl URL can be templated with `{crate}` and `{version}` to
have more control over the resulting path.
For backwards compatibility, we append the default template suffix onto
the dl URL if neither of the template parameters are present for
backwards compatibility.
Member
withoutboats
approved these changes
Dec 19, 2017
Contributor
withoutboats
left a comment
There was a problem hiding this comment.
Looks good overall, just a tiny nit about an allocation.
src/cargo/sources/registry/remote.rs
Outdated
| .push("download"); | ||
| let mut url = config.dl.clone(); | ||
| if !url.contains(CRATE_TEMPLATE) && !url.contains(VERSION_TEMPLATE) { | ||
| let suffix = format!("/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE); |
Contributor
There was a problem hiding this comment.
Total nit but this intermediate allocation bothers me, can't we do write!(url, "/{}/{}/downloads", ...)?
Contributor
|
Note: we cannot change crates.io to use this syntax because the registry needs to support older versions of cargo. So the backwards compatible form will be used by the registry indefinitely. |
Member
Author
|
Updated! |
Contributor
|
@bors r+ |
Contributor
|
📌 Commit 52f099b has been approved by |
Contributor
bors
added a commit
that referenced
this pull request
Dec 19, 2017
Template a registry's dl field
Previously, crate files were always downloaded from
`/{crate}/{version}/download`. However, if the backing crate store for a
custom registry is a raw file server rather than an API endpoint that
requires every file to be named `download` which is a bit weird. Now a
registry's dl URL can be templated with `{crate}` and `{version}` to
have more control over the resulting path.
For backwards compatibility, we append the default template suffix onto
the dl URL if neither of the template parameters are present for
backwards compatibility.
r? @alexcrichton
cc @withoutboats
Contributor
|
☀️ Test successful - status-appveyor, status-travis |
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.
Previously, crate files were always downloaded from
/{crate}/{version}/download. However, if the backing crate store for acustom registry is a raw file server rather than an API endpoint that
requires every file to be named
downloadwhich is a bit weird. Now aregistry's dl URL can be templated with
{crate}and{version}tohave more control over the resulting path.
For backwards compatibility, we append the default template suffix onto
the dl URL if neither of the template parameters are present for
backwards compatibility.
r? @alexcrichton
cc @withoutboats