From 4a70708e074aec9cde543c829cff9e162b818f8b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 30 Jul 2026 21:39:13 -0400 Subject: [PATCH] Wait for an open transaction before vacuuming the embeddings database SQLite can't vacuum from within a transaction, and the idle handler that vacuums the attached database can run while other work has one open. --- chrome/content/zotero/xpcom/embeddings.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chrome/content/zotero/xpcom/embeddings.js b/chrome/content/zotero/xpcom/embeddings.js index b48cfbbd25..c5c5f30fc2 100644 --- a/chrome/content/zotero/xpcom/embeddings.js +++ b/chrome/content/zotero/xpcom/embeddings.js @@ -304,6 +304,9 @@ Zotero.Embeddings = new function () { * @return {Promise} - Whether the database was vacuumed */ this.vacuumDB = async function ({ force = false } = {}) { + if (Zotero.DB.inTransaction()) { + await Zotero.DB.waitForTransaction(); + } if (!force) { let freelistCount = await Zotero.DB.valueQueryAsync("PRAGMA embeddings.freelist_count"); let pageCount = await Zotero.DB.valueQueryAsync("PRAGMA embeddings.page_count");