From c5e1e2ec62212902646fd5a8fb0139cf37cf40c7 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 3 Mar 2023 17:21:39 +0100 Subject: [PATCH] Commit the DB transaction at the end of the cleanup task --- crates/tasks/src/database.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/tasks/src/database.rs b/crates/tasks/src/database.rs index ebade53a..ae9dfac8 100644 --- a/crates/tasks/src/database.rs +++ b/crates/tasks/src/database.rs @@ -14,7 +14,7 @@ //! Database-related tasks -use mas_storage::{oauth2::OAuth2AccessTokenRepository, RepositoryAccess, SystemClock}; +use mas_storage::{oauth2::OAuth2AccessTokenRepository, Repository, RepositoryAccess, SystemClock}; use mas_storage_pg::PgRepository; use sqlx::{Pool, Postgres}; use tracing::{debug, error, info}; @@ -34,8 +34,9 @@ impl std::fmt::Debug for CleanupExpired { impl Task for CleanupExpired { async fn run(&self) { let res = async move { - let mut repo = PgRepository::from_pool(&self.0).await?; + let mut repo = PgRepository::from_pool(&self.0).await?.boxed(); let res = repo.oauth2_access_token().cleanup_expired(&self.1).await; + repo.save().await?; res } .await;