diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-10-31 10:44:31 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-10-31 10:44:31 -0400 |
commit | 050e40c03900827057ab5db2f6bbe971a6408fda (patch) | |
tree | caa3a97208d077e2206f735f9ecd6618b4ac9ebf /dichroism/src/handlers.rs | |
parent | 3e1eadbbfdca1b2c0cb32ba4c8e1160a60e0ccb8 (diff) | |
download | theglassyladies-050e40c03900827057ab5db2f6bbe971a6408fda.tar.xz theglassyladies-050e40c03900827057ab5db2f6bbe971a6408fda.zip |
blocking on photo set generation since it hits the fs
Diffstat (limited to 'dichroism/src/handlers.rs')
-rw-r--r-- | dichroism/src/handlers.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/dichroism/src/handlers.rs b/dichroism/src/handlers.rs index 7c1d302..0480abf 100644 --- a/dichroism/src/handlers.rs +++ b/dichroism/src/handlers.rs @@ -43,10 +43,12 @@ async fn patch_product( if let Some(data_uri) = patch.photo_data { // create new photo_set - let photo_set = image_service::generate_photo_set(&data_uri).map_err(|e| { - eprintln!("{}", e.to_string()); - HttpResponse::InternalServerError().body(e.to_string()) - })?; + let photo_set = web::block(move || image_service::generate_photo_set(&data_uri)) + .await + .map_err(|e| { + eprintln!("{}", e.to_string()); + HttpResponse::InternalServerError().body(e.to_string()) + })?; let conn = pool.get().map_err(to_internal_error)?; let photo_set = web::block(move || repo::store_photo_set(&conn, photo_set)) .await @@ -79,10 +81,13 @@ async fn post_product( let post = post.into_inner(); // create new photo_set - let photo_set = image_service::generate_photo_set(&post.photo_data).map_err(|e| { - eprintln!("{}", e.to_string()); - HttpResponse::InternalServerError().body(e.to_string()) - })?; + let data_uri = post.photo_data; + let photo_set = web::block(move || image_service::generate_photo_set(&data_uri)) + .await + .map_err(|e| { + eprintln!("{}", e.to_string()); + HttpResponse::InternalServerError().body(e.to_string()) + })?; let conn = pool.get().map_err(to_internal_error)?; let photo_set = web::block(move || repo::store_photo_set(&conn, photo_set)) .await |