From 3fbc8b130d86542efb0b6007b7e4a95428ed8c8d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 16 Sep 2020 08:29:51 -0500 Subject: [PATCH] Adding site checking. --- src/api/site.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/api/site.rs b/src/api/site.rs index 285c57569..4d6438a15 100644 --- a/src/api/site.rs +++ b/src/api/site.rs @@ -142,10 +142,9 @@ impl Perform for CreateSite { ) -> Result { let data: &CreateSite = &self; - match blocking(context.pool(), move |conn| { Site::read(conn, 1)}).await? - { - Ok(_site) => return Err(APIError::err("site_already_exists").into()), - Err(_e) => (), + let read_site = move |conn: &'_ _| Site::read(conn, 1); + if blocking(context.pool(), read_site).await?.is_ok() { + return Err(APIError::err("site_already_exists").into()); }; let user = get_user_from_jwt(&data.auth, context.pool()).await?;