From cb41a2ecd6898181dc35440964d0c60ed781ae11 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Nov 2013 15:54:31 -0500 Subject: [PATCH] Don't use single DB transaction when rebuilding full-text index This might slow down the rebuild, but it will hopefully also prevent excessive memory usage and crashing. --- chrome/content/zotero/xpcom/fulltext.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index 64044b38f7..4e411bfaee 100644 --- a/chrome/content/zotero/xpcom/fulltext.js +++ b/chrome/content/zotero/xpcom/fulltext.js @@ -425,6 +425,8 @@ Zotero.Fulltext = new function(){ } } + Zotero.DB.beginTransaction(); + this.indexString(text, charset, itemID); // Record the number of characters indexed (unless we're indexing a (PDF) cache file, @@ -433,6 +435,8 @@ Zotero.Fulltext = new function(){ this.setChars(itemID, { indexed: text.length, total: totalChars }); } + Zotero.DB.commitTransaction(); + return true; } @@ -540,8 +544,6 @@ Zotero.Fulltext = new function(){ var items = Zotero.Items.get(items); var found = []; - Zotero.DB.beginTransaction(); - for each (let item in items) { if (!item.isAttachment()) { continue; @@ -569,8 +571,6 @@ Zotero.Fulltext = new function(){ this.indexFile(file, item.attachmentMIMEType, item.attachmentCharset, itemID, complete); } } - - Zotero.DB.commitTransaction(); } @@ -1351,8 +1351,6 @@ Zotero.Fulltext = new function(){ function rebuildIndex(unindexedOnly){ - Zotero.DB.beginTransaction(); - // Get all attachments other than web links var sql = "SELECT itemID FROM itemAttachments WHERE linkMode!=" + Zotero.Attachments.LINK_MODE_LINKED_URL; @@ -1362,11 +1360,13 @@ Zotero.Fulltext = new function(){ } var items = Zotero.DB.columnQuery(sql); if (items) { + Zotero.DB.beginTransaction(); Zotero.DB.query("DELETE FROM fulltextItemWords WHERE itemID IN (" + sql + ")"); Zotero.DB.query("DELETE FROM fulltextItems WHERE itemID IN (" + sql + ")"); + Zotero.DB.commitTransaction(); + this.indexItems(items, false, true); } - Zotero.DB.commitTransaction(); }