Obey crates.io crawler policy: Only make one request per sec (#908)

Fixed https://github.com/taiki-e/install-action/issues/89

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-14 17:11:22 +11:00 committed by GitHub
parent f37796a55f
commit d118fa8fdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 1 deletions

View file

@ -354,7 +354,15 @@ impl PackageInfo {
// Fetch crate via crates.io, git, or use a local manifest path
let manifest = match opts.manifest_path.as_ref() {
Some(manifest_path) => load_manifest_path(manifest_path)?,
None => Box::pin(fetch_crate_cratesio(client, &name, version_req)).await?,
None => {
Box::pin(fetch_crate_cratesio(
client,
&name,
version_req,
&opts.crates_io_rate_limit,
))
.await?
}
};
let Some(mut package) = manifest.package else {