From eb4375258e7e1e6c5931ec12fd9ce3a250d5c191 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Sun, 6 Feb 2022 17:54:01 -0700 Subject: [PATCH] Fix routing errors 2 + Version File Response (#290) --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/routes/tags.rs | 2 +- src/routes/version_file.rs | 13 +++++++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5bb58ea7..2b21f933b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1653,6 +1653,7 @@ dependencies = [ "futures", "futures-timer", "gumdrop", + "hex", "lazy_static", "log", "meilisearch-sdk", diff --git a/Cargo.toml b/Cargo.toml index 026d67d3b..e7afafcff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,4 +58,5 @@ sqlx = { version = "0.5.10", features = ["runtime-actix-rustls", "postgres", "ch bytes = "1.1.0" -dashmap = "4.0.2" \ No newline at end of file +dashmap = "4.0.2" +hex = "0.4.3" \ No newline at end of file diff --git a/src/routes/tags.rs b/src/routes/tags.rs index e7b80f7f5..1d7747dc5 100644 --- a/src/routes/tags.rs +++ b/src/routes/tags.rs @@ -8,7 +8,7 @@ use sqlx::PgPool; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service( - web::scope("/tag/") + web::scope("tag") .service(category_list) .service(category_create) .service(category_delete) diff --git a/src/routes/version_file.rs b/src/routes/version_file.rs index f52d112c7..420973708 100644 --- a/src/routes/version_file.rs +++ b/src/routes/version_file.rs @@ -379,7 +379,7 @@ pub struct FileHashes { } // under /api/v2/version_files -#[post("/")] +#[post("")] pub async fn get_versions_from_hashes( pool: web::Data, file_data: web::Json, @@ -418,7 +418,12 @@ pub async fn get_versions_from_hashes( .clone() .into_iter() .find(|x| x.id.0 == row.version_id) - .map(|v| (row.hash, crate::models::projects::Version::from(v))) + .map(|v| { + ( + hex::encode(row.hash), + crate::models::projects::Version::from(v), + ) + }) }) .collect(); Ok(HttpResponse::Ok().json(response)) @@ -463,7 +468,7 @@ pub async fn download_files( &pepper, ) .await?; - response.insert(row.hash, row.url); + response.insert(hex::encode(row.hash), row.url); } Ok(HttpResponse::Ok().json(response)) @@ -540,7 +545,7 @@ pub async fn update_files( for row in &result { if let Some(version) = versions.iter().find(|x| x.id.0 == row.version_id) { response.insert( - row.hash.clone(), + hex::encode(&row.hash), models::projects::Version::from(version.clone()), ); }