From a7ea92fd529e2b41b7e35db1ad058566a6ab70c7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 15 May 2016 01:30:35 -0400 Subject: [PATCH] Mark items with missing full-text cache files as unsynced for full text Fixes #954, Full-text content processor tries to process missing cache files on every idle --- chrome/content/zotero/xpcom/fulltext.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index 5b61bf3f3..015fa1e12 100644 --- a/chrome/content/zotero/xpcom/fulltext.js +++ b/chrome/content/zotero/xpcom/fulltext.js @@ -1038,6 +1038,8 @@ Zotero.Fulltext = Zotero.FullText = new function(){ } /** + * Find items marked as having unprocessed cache files, run cache file processing on one item, and + * after a short delay call self again with the remaining items * * @param {Array} itemIDs An array of itemIDs to process; if this * is omitted, a database query is made @@ -1076,6 +1078,8 @@ Zotero.Fulltext = Zotero.FullText = new function(){ yield Zotero.Fulltext.indexFromProcessorCache(itemID); + // If there are remaining items, call self again after a short delay. The delay allows for + // processing to be interrupted if the user returns from idle if (itemIDs.length) { if (!_processorTimer) { _processorTimer = Components.classes["@mozilla.org/timer;1"] @@ -1119,6 +1123,9 @@ Zotero.Fulltext = Zotero.FullText = new function(){ var cacheFile = this.getItemProcessorCacheFile(item); if (!cacheFile.exists()) { Zotero.debug("Full-text content processor cache file doesn't exist for item " + itemID); + yield Zotero.DB.queryAsync( + "UPDATE fulltextItems SET synced=? WHERE itemID=?", [SYNC_STATE_UNSYNCED, itemID] + ); return false; }