Reduce memory consumption of full-text index clear

This commit is contained in:
Dan Stillman 2018-08-19 03:59:34 -04:00
parent 18021d1aeb
commit 926e2f7317

View file

@ -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);
await Zotero.DB.queryAsync(sql);
});
if (skipLinkedURLs) {
yield this.purgeUnusedWords();
await this.purgeUnusedWords();
}
else {
yield Zotero.DB.queryAsync("DELETE FROM fulltextWords");
await Zotero.DB.queryAsync("DELETE FROM fulltextWords");
}
yield clearCacheFiles();
}.bind(this));
await clearCacheFiles();
}