Skip startup full-text index purge and optimize when unnecessary

purgeOrphanedContent() ran on every startup, unlike the other
data-object purges, which are gated on the purge.* prefs.
startQueueDrain() also ran an FTS5 'optimize' even when the queues were
empty.

Gate the former on purge.items and the latter on having indexed
something.

(cherry picked from commit 8f6dc583b8)
This commit is contained in:
Dan Stillman 2026-08-05 15:13:43 -04:00
parent 06329d3379
commit 2b7057a12e
2 changed files with 7 additions and 2 deletions

View file

@ -1817,7 +1817,9 @@ Zotero.Fulltext = Zotero.FullText = new function () {
itemProgress.setProgress(100);
}
}
await this.optimizeContentIndex();
if (done > 0) {
await this.optimizeContentIndex();
}
// Reclaim the space freed by a rebuild (e.g., an index-format change dropping the old
// tables), which can be most of the file; the freelist gate makes this a no-op on
// ordinary startups

View file

@ -1971,7 +1971,10 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte
await Zotero.DB.executeTransaction(async function () {
return Zotero.Tags.purge();
});
await Zotero.FullText.purgeOrphanedContent();
// Items.purge() below resets the pref
if (Zotero.Prefs.get('purge.items')) {
await Zotero.FullText.purgeOrphanedContent();
}
await Zotero.Items.purge();
// DEBUG: this might not need to be permanent
//yield Zotero.DB.executeTransaction(async function () {