improvement: flush after every request that manipulates the db

This commit is contained in:
Timo Kösters 2020-10-21 21:28:02 +02:00
parent b2a1505535
commit 6dbe195695
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
30 changed files with 216 additions and 105 deletions

View file

@ -16,7 +16,7 @@ use rocket::{get, put};
feature = "conduit_bin",
put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)]
pub fn set_global_account_data_route(
pub async fn set_global_account_data_route(
db: State<'_, Database>,
body: Ruma<set_global_account_data::Request<'_>>,
) -> ConduitResult<set_global_account_data::Response> {
@ -40,6 +40,8 @@ pub fn set_global_account_data_route(
&db.globals,
)?;
db.flush().await?;
Ok(set_global_account_data::Response.into())
}
@ -47,7 +49,7 @@ pub fn set_global_account_data_route(
feature = "conduit_bin",
get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)]
pub fn get_global_account_data_route(
pub async fn get_global_account_data_route(
db: State<'_, Database>,
body: Ruma<get_global_account_data::Request<'_>>,
) -> ConduitResult<get_global_account_data::Response> {
@ -58,5 +60,7 @@ pub fn get_global_account_data_route(
.get::<Raw<ruma::events::AnyBasicEvent>>(None, sender_user, body.event_type.clone().into())?
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Data not found."))?;
db.flush().await?;
Ok(get_global_account_data::Response { account_data: data }.into())
}