diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js index d974b58175..4b02125898 100644 --- a/chrome/content/zotero/xpcom/fulltext.js +++ b/chrome/content/zotero/xpcom/fulltext.js @@ -1427,31 +1427,36 @@ Zotero.Fulltext = Zotero.FullText = new function(){ } + this.canIndex = function (item) { + if (!item.isAttachment() + || item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL) { + return false; + } + var contentType = item.attachmentContentType; + return contentType + && (contentType == 'application/pdf' + || contentType == 'application/epub+zip' + || Zotero.MIME.isTextType(contentType)); + }; + + /* * Returns true if an item can be reindexed * * Item must be a non-web-link attachment that isn't already fully indexed */ this.canReindex = Zotero.Promise.coroutine(function* (item) { - if (item.isAttachment() - && item.attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) { - let contentType = item.attachmentContentType; - if (!contentType - || contentType != 'application/pdf' - && contentType != 'application/epub+zip' - && !Zotero.MIME.isTextType(contentType)) { - return false; - } - switch (yield this.getIndexedState(item)) { - case this.INDEX_STATE_UNAVAILABLE: - case this.INDEX_STATE_UNINDEXED: - case this.INDEX_STATE_PARTIAL: - case this.INDEX_STATE_QUEUED: - - // TODO: automatically reindex already-indexed attachments? - case this.INDEX_STATE_INDEXED: - return true; - } + if (!item.canIndex(item)) { + return false; + } + switch (yield this.getIndexedState(item)) { + case this.INDEX_STATE_UNAVAILABLE: + case this.INDEX_STATE_UNINDEXED: + case this.INDEX_STATE_PARTIAL: + case this.INDEX_STATE_QUEUED: + // TODO: automatically reindex already-indexed attachments? + case this.INDEX_STATE_INDEXED: + return true; } return false; }); diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js index afe0180726..dcd26e00f1 100644 --- a/chrome/content/zotero/xpcom/mime.js +++ b/chrome/content/zotero/xpcom/mime.js @@ -120,7 +120,7 @@ Zotero.MIME = new function(){ function isTextType(mimeType) { - return mimeType.substr(0, 5) == 'text/' || _textTypes[mimeType]; + return mimeType.substr(0, 5) == 'text/' || mimeType in _textTypes; } this.isWebPageType = function(mimeType) {