mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
fix: explicitly close the database on account removal
This commit is contained in:
@@ -166,6 +166,14 @@ impl Accounts {
|
|||||||
.remove(&id)
|
.remove(&id)
|
||||||
.with_context(|| format!("no account with id {id}"))?;
|
.with_context(|| format!("no account with id {id}"))?;
|
||||||
ctx.stop_io().await;
|
ctx.stop_io().await;
|
||||||
|
|
||||||
|
// Explicitly close the database.
|
||||||
|
//
|
||||||
|
// Stopping I/O aborts the tasks that keep `Context` clones,
|
||||||
|
// but aborting the task does not immediately drops the future.
|
||||||
|
// To make sure the database file is closed
|
||||||
|
// and can be removed on Windows, we drop all the connections manually.
|
||||||
|
ctx.sql.close().await;
|
||||||
drop(ctx);
|
drop(ctx);
|
||||||
|
|
||||||
if let Some(cfg) = self.config.get_account(id) {
|
if let Some(cfg) = self.config.get_account(id) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ impl Sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Closes all underlying Sqlite connections.
|
/// Closes all underlying Sqlite connections.
|
||||||
async fn close(&self) {
|
pub(crate) async fn close(&self) {
|
||||||
let _ = self.pool.write().await.take();
|
let _ = self.pool.write().await.take();
|
||||||
// drop closes the connection
|
// drop closes the connection
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user