1
Fork 0
mirror of https://github.com/Steffo99/distributed-arcade.git synced 2024-11-24 09:04:25 +00:00

route_board_post: Start transaction earlier to account for empty key checks

This commit is contained in:
Steffo 2022-11-21 18:21:28 +01:00
parent 7555b10a06
commit 2b95aea509
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -141,6 +141,11 @@ pub(crate) async fn route_board_post(
let mut rconn = rclient.get_connection_or_504().await?;
log::trace!("Ensuring a board does not already exist...");
log::trace!("Starting Redis transaction...");
redis::cmd("MULTI").query_async(&mut rconn).await
.map_err(outcome::redis_cmd_failed)?;
ensure_key_is_empty(&mut rconn, &order_key).await?;
ensure_key_is_empty(&mut rconn, &token_key).await?;
ensure_key_is_empty(&mut rconn, &scores_key).await?;
@ -149,10 +154,6 @@ pub(crate) async fn route_board_post(
log::debug!("Creating board: {name:?}");
log::trace!("Starting Redis transaction...");
redis::cmd("MULTI").query_async(&mut rconn).await
.map_err(outcome::redis_cmd_failed)?;
log::trace!("Setting board order...");
rconn.set(&order_key, Into::<&str>::into(order)).await
.map_err(outcome::redis_cmd_failed)?;