]> git.proxmox.com Git - cargo.git/commit
Auto merge of #8267 - drmikehenry:prefix, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 8 Jun 2020 14:19:43 +0000 (14:19 +0000)
committerbors <bors@rust-lang.org>
Mon, 8 Jun 2020 14:19:43 +0000 (14:19 +0000)
commit22a112bff1a44817983681caf7324261c2393e54
treea4f34574d4f6b6b2c53d4bc6220041421728f37c
parent6f9d8083236d8b1ae8455a04782919326b06951c
parentb375bea147edda469b3442b9e89390180a442256
Auto merge of #8267 - drmikehenry:prefix, r=alexcrichton

Support `{prefix}` and `{lowerprefix}` markers in `config.json` `dl` key

Hello,

The crates.io-index Git repository uses a nice directory structure to keep individual directory sizes under control.

When mirroring crates.io, it's useful to store crate files in a similar directory structure for the same reasons.

Cargo provides "markers" for use in the `dl` key of the `config.json` file in crates.io-index to allow flexibility in mapping a crate's name and version into a URL for the crate.  The marker `{crate}` is replaced by the crate's name, and the marker `{version}` is replaced with the crate's version.  The default URL template is `https://crates.io/api/v1/crates/{crate}/{version}/download`.

Currently, if a mirror of crates.io stores crates in a directory structure similar to that of crates.io-index, it's up to the server to construct the directory name from the crate name.  This eliminates trivial web servers and `file:` URLs from hosting such a tree of crates.

This pull requests adds two new markers for the `dl` key in `config.json`, allowing Cargo to supply the directory name as part of the URL.  The marker `{lowerprefix}` is the same directory name used within crates.io-index; it is calculated from the crate name converted to lowercase.  The marker `{prefix}` is similar, but it uses the crate name as-is (without case conversion), which is useful for supporting older versions of Cargo that lack these markers; for example, nginx rewrite rules can easily construct `{prefix}` but can't perform case-conversion to construct `{lowerprefix}`.  These new markers will provide implementation flexibility and simplicity for crate mirror servers.