diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index e1502e7a5..3a646f167 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