mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 15:42:10 +03:00
sql: expect zero-column results from PRAGMA incremental_vacuum
The fact that `PRAGMA incremental_vacuum` may return a zero-column SQLITE_ROW result is documented in `sqlite3_data_count()` documentation: <https://www.sqlite.org/c3ref/data_count.html> Previously successful auto_vacuum worked, but resulted in a "Failed to run incremental vacuum" log.
This commit is contained in:
16
src/sql.rs
16
src/sql.rs
@@ -713,12 +713,22 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
|
||||
|
||||
// Try to clear the freelist to free some space on the disk. This
|
||||
// only works if auto_vacuum is enabled.
|
||||
if let Err(err) = context
|
||||
match context
|
||||
.sql
|
||||
.execute("PRAGMA incremental_vacuum", paramsv![])
|
||||
.query_row_optional("PRAGMA incremental_vacuum", (), |_row| Ok(()))
|
||||
.await
|
||||
{
|
||||
warn!(context, "Failed to run incremental vacuum: {}", err);
|
||||
Err(err) => {
|
||||
warn!(context, "Failed to run incremental vacuum: {err:#}");
|
||||
}
|
||||
Ok(Some(())) => {
|
||||
// Incremental vacuum returns a zero-column result if it did anything.
|
||||
info!(context, "Successfully ran incremental vacuum.");
|
||||
}
|
||||
Ok(None) => {
|
||||
// Incremental vacuum returned `SQLITE_DONE` immediately,
|
||||
// there were no pages to remove.
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(e) = context
|
||||
|
||||
Reference in New Issue
Block a user