diff --git a/services/blob/src/http/context.rs b/services/blob/src/http/context.rs --- a/services/blob/src/http/context.rs +++ b/services/blob/src/http/context.rs @@ -33,22 +33,6 @@ Err(err) => Err(handle_db_error(err)), } } - - pub async fn find_s3_path_by_holder( - &self, - holder: &str, - ) -> Result { - match self.db.find_reverse_index_by_holder(holder).await { - Ok(Some(reverse_index)) => { - self.find_s3_path_by_reverse_index(&reverse_index).await - } - Ok(None) => { - debug!("No db entry found for holder {:?}", holder); - Err(ErrorNotFound("blob not found")) - } - Err(err) => Err(handle_db_error(err)), - } - } } pub fn handle_db_error(db_error: DBError) -> HttpError { diff --git a/services/blob/src/http/handlers/blob.rs b/services/blob/src/http/handlers/blob.rs --- a/services/blob/src/http/handlers/blob.rs +++ b/services/blob/src/http/handlers/blob.rs @@ -21,17 +21,24 @@ #[instrument( name = "get_blob", skip_all, - fields(holder = %params.as_ref().as_str(), s3_path)) + fields(blob_hash = %params.as_ref().as_str(), s3_path)) ] pub async fn get_blob_handler( ctx: web::Data, params: web::Path, ) -> actix_web::Result { info!("Get blob request"); - let holder = params.into_inner(); - validate_identifier!(holder); + let blob_hash = params.into_inner(); + validate_identifier!(blob_hash); - let s3_path = ctx.find_s3_path_by_holder(&holder).await?; + let s3_path = match ctx.db.find_blob_item(&blob_hash).await { + Ok(Some(BlobItem { s3_path, .. })) => Ok(s3_path), + Ok(None) => { + debug!("Blob with given hash not found in database"); + Err(ErrorNotFound("blob not found")) + } + Err(err) => Err(handle_db_error(err)), + }?; tracing::Span::current().record("s3_path", s3_path.to_full_path()); let object_metadata = ctx