Skip to content

Conversation

sfackler
Copy link
Member

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

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.
@alexcrichton
Copy link
Member

r? @withoutboats

Copy link
Contributor

@withoutboats withoutboats left a comment

Choose a reason for hiding this comment

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

Looks good overall, just a tiny nit about an allocation.

.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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nit but this intermediate allocation bothers me, can't we do write!(url, "/{}/{}/downloads", ...)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep that'd also work.

@withoutboats
Copy link
Contributor

withoutboats commented Dec 19, 2017

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.

@sfackler
Copy link
Member Author

sfackler commented Dec 19, 2017

Updated!

@withoutboats
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 19, 2017

📌 Commit 52f099b has been approved by withoutboats

@bors
Copy link
Contributor

bors commented Dec 19, 2017

⌛ Testing commit 52f099b with merge 77a773a...

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
@bors
Copy link
Contributor

bors commented Dec 19, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: withoutboats
Pushing 77a773a to master...

@bors bors merged commit 52f099b into rust-lang:master Dec 19, 2017
@sfackler sfackler deleted the dl-template branch December 19, 2017 06:02
@ehuss ehuss added this to the 1.24.0 milestone Feb 6, 2022
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.

5 participants