From 926e2f7317915645ca9f1a457f45762f157d4263 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 19 Aug 2018 03:59:34 -0400 Subject: [PATCH] Reduce memory consumption of full-text index clear --- chrome/content/zotero/xpcom/fulltext.js | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index 74d10c3bfb..5ee16c9add 100644 --- a/chrome/content/zotero/xpcom/fulltext.js +++ b/chrome/content/zotero/xpcom/fulltext.js @@ -1447,8 +1447,8 @@ Zotero.Fulltext = Zotero.FullText = new function(){ * * @return {Promise} */ - this.clearIndex = function (skipLinkedURLs) { - return Zotero.DB.executeTransaction(function* () { + this.clearIndex = async function (skipLinkedURLs) { + await Zotero.DB.executeTransaction(async function () { var sql = "DELETE FROM fulltextItems"; if (skipLinkedURLs) { var linkSQL = "SELECT itemID FROM itemAttachments WHERE linkMode =" @@ -1456,23 +1456,23 @@ Zotero.Fulltext = Zotero.FullText = new function(){ sql += " WHERE itemID NOT IN (" + linkSQL + ")"; } - yield Zotero.DB.queryAsync(sql); + await Zotero.DB.queryAsync(sql); sql = "DELETE FROM fulltextItemWords"; if (skipLinkedURLs) { sql += " WHERE itemID NOT IN (" + linkSQL + ")"; } - yield Zotero.DB.queryAsync(sql); - - if (skipLinkedURLs) { - yield this.purgeUnusedWords(); - } - else { - yield Zotero.DB.queryAsync("DELETE FROM fulltextWords"); - } - - yield clearCacheFiles(); - }.bind(this)); + await Zotero.DB.queryAsync(sql); + }); + + if (skipLinkedURLs) { + await this.purgeUnusedWords(); + } + else { + await Zotero.DB.queryAsync("DELETE FROM fulltextWords"); + } + + await clearCacheFiles(); }