From c110e642932143d15ad1b2f5c015181775b6ef99 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 26 Jul 2017 06:07:47 -0400 Subject: [PATCH] Consider fulltextItems with SYNC_STATE_MISSING as unindexed The items will still match full-text word searches, but they won't match phrase searches (because those require cache files for non-text attachments) and the full-text won't sync to other computers, so they should really be reindexed. --- chrome/content/zotero/xpcom/fulltext.js | 35 ++++++++++++++----------- test/tests/fulltextTest.js | 4 +++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index e1502e7a5a..3a646f167c 100644 --- a/chrome/content/zotero/xpcom/fulltext.js +++ b/chrome/content/zotero/xpcom/fulltext.js @@ -1506,6 +1506,14 @@ Zotero.Fulltext = Zotero.FullText = new function(){ throw new Error('Item is not an attachment'); } + // If the file or cache file wasn't available during syncing, mark as unindexed + var synced = yield Zotero.DB.valueQueryAsync( + "SELECT synced FROM fulltextItems WHERE itemID=?", item.id + ); + if (synced === false || synced == this.SYNC_STATE_MISSING) { + return this.INDEX_STATE_UNINDEXED; + } + var itemID = item.id; switch (item.attachmentContentType) { // Use pages for PDFs @@ -1570,10 +1578,10 @@ Zotero.Fulltext = Zotero.FullText = new function(){ * @return {Promise} */ this.getIndexStats = Zotero.Promise.coroutine(function* () { - var sql = "SELECT COUNT(*) FROM fulltextItems WHERE " - + "(indexedPages IS NOT NULL AND indexedPages=totalPages) OR " - + "(indexedChars IS NOT NULL AND indexedChars=totalChars)" - var indexed = yield Zotero.DB.valueQueryAsync(sql); + var sql = "SELECT COUNT(*) FROM fulltextItems WHERE synced != ? AND " + + "((indexedPages IS NOT NULL AND indexedPages=totalPages) OR " + + "(indexedChars IS NOT NULL AND indexedChars=totalChars))" + var indexed = yield Zotero.DB.valueQueryAsync(sql, this.SYNC_STATE_MISSING); var sql = "SELECT COUNT(*) FROM fulltextItems WHERE " + "(indexedPages IS NOT NULL AND indexedPages