Skip to content

Commit d7ec981

Browse files
committed
Auto merge of #3514 - jtgeibel:non-canonical-dl, r=pietroalbini
Log a flag for downloads with non-canonical crate names We could instead include the corrected name, but that doesn't seem very useful and this is already something I search the logs for occasionally. This change will allow us to collect some data to see if it would be practical to blindly redirect the request if there is an issue obtaining a database connection from the pool. r? `@pietroalbini`
2 parents 26be2d3 + e9164e1 commit d7ec981

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/controllers/version/downloads.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn download(req: &mut dyn RequestExt) -> EndpointResult {
2020
let crate_name = &req.params()["crate_id"];
2121
let version = &req.params()["version"];
2222

23-
let (version_id, crate_name): (_, String) = {
23+
let (version_id, canonical_crate_name): (_, String) = {
2424
use self::versions::dsl::*;
2525

2626
let conn = recorder.record("get_conn", || req.db_conn())?;
@@ -45,7 +45,11 @@ pub fn download(req: &mut dyn RequestExt) -> EndpointResult {
4545
.app()
4646
.config
4747
.uploader
48-
.crate_location(&crate_name, version);
48+
.crate_location(&canonical_crate_name, version);
49+
50+
if &canonical_crate_name != crate_name {
51+
req.log_metadata("bot", "dl");
52+
}
4953

5054
if req.wants_json() {
5155
#[derive(Serialize)]

0 commit comments

Comments
 (0)