+
Skip to content

fix: explicitly close the database on account removal #5814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ impl Accounts {
.remove(&id)
.with_context(|| format!("no account with id {id}"))?;
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);

if let Some(cfg) = self.config.get_account(id) {
Expand Down
2 changes: 1 addition & 1 deletion src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Sql {
}

/// Closes all underlying Sqlite connections.
async fn close(&self) {
pub(crate) async fn close(&self) {
let _ = self.pool.write().await.take();
// drop closes the connection
}
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载