diff mbox series

[1/1] fetch2/crate: use CDN for fetching crates

Message ID 20260427135122.1504143-2-johanam@axis.com
State Accepted, archived
Commit f3904634889e737861b47d6bf4068faac4d4661d
Headers show
Series crates.io data access policy | expand

Commit Message

Johan Anderholm April 27, 2026, 1:51 p.m. UTC
This avoids the 1 req/sec that the API has.

Reference: https://github.com/rust-lang/crates.io/issues/13482
Reference: https://blog.rust-lang.org/2024/03/11/crates-io-download-changes/
Signed-off-by: Johan Anderholm <johanam@axis.com>
---
 lib/bb/fetch2/crate.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py
index e611736f0..2d3078899 100644
--- a/lib/bb/fetch2/crate.py
+++ b/lib/bb/fetch2/crate.py
@@ -68,8 +68,11 @@  class Crate(Wget):
         # if using upstream just fix it up nicely
         if host == 'crates.io':
             host = 'crates.io/api/v1/crates'
+            cdn_host = 'static.crates.io/crates'
+        else:
+            cdn_host = host
 
-        ud.url = "https://%s/%s/%s/download" % (host, name, version)
+        ud.url = "https://%s/%s/%s/download" % (cdn_host, name, version)
         ud.versionsurl = "https://%s/%s/versions" % (host, name)
         ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version)
         if 'name' not in ud.parm: