Show "Queued" in right pane for unprocessed full-text and allow indexing

This commit is contained in:
Dan Stillman 2017-08-06 18:50:03 +02:00
parent fffa1badd4
commit 07ce273333
3 changed files with 53 additions and 48 deletions

View File

@ -525,6 +525,9 @@
case Zotero.Fulltext.INDEX_STATE_PARTIAL: case Zotero.Fulltext.INDEX_STATE_PARTIAL:
str += 'partial'; str += 'partial';
break; break;
case Zotero.Fulltext.INDEX_STATE_QUEUED:
str += 'queued';
break;
case Zotero.Fulltext.INDEX_STATE_INDEXED: case Zotero.Fulltext.INDEX_STATE_INDEXED:
str = 'general.yes'; str = 'general.yes';
break; break;

View File

@ -38,10 +38,11 @@ Zotero.Fulltext = Zotero.FullText = new function(){
this.__defineGetter__("pdfConverterCacheFile", function () { return '.zotero-ft-cache'; }); this.__defineGetter__("pdfConverterCacheFile", function () { return '.zotero-ft-cache'; });
this.__defineGetter__("pdfInfoCacheFile", function () { return '.zotero-ft-info'; }); this.__defineGetter__("pdfInfoCacheFile", function () { return '.zotero-ft-info'; });
this.__defineGetter__("INDEX_STATE_UNAVAILABLE", function () { return 0; }); this.INDEX_STATE_UNAVAILABLE = 0;
this.__defineGetter__("INDEX_STATE_UNINDEXED", function () { return 1; }); this.INDEX_STATE_UNINDEXED = 1;
this.__defineGetter__("INDEX_STATE_PARTIAL", function () { return 2; }); this.INDEX_STATE_PARTIAL = 2;
this.__defineGetter__("INDEX_STATE_INDEXED", function () { return 3; }); this.INDEX_STATE_INDEXED = 3;
this.INDEX_STATE_QUEUED = 4;
this.SYNC_STATE_UNSYNCED = 0; this.SYNC_STATE_UNSYNCED = 0;
this.SYNC_STATE_IN_SYNC = 1; this.SYNC_STATE_IN_SYNC = 1;
@ -789,8 +790,13 @@ Zotero.Fulltext = Zotero.FullText = new function(){
var path = yield item.getFilePathAsync(); var path = yield item.getFilePathAsync();
if (!path) { if (!path) {
Zotero.debug("No file to index for item " + item.libraryKey if (yield OS.File.exists(this.getItemProcessorCacheFile(item).path)) {
+ " in Zotero.FullText.indexItems()"); yield Zotero.Fulltext.indexFromProcessorCache(itemID);
}
else {
Zotero.debug("No file to index for item " + item.libraryKey
+ " in Zotero.FullText.indexItems()");
}
continue; continue;
} }
@ -1515,57 +1521,51 @@ Zotero.Fulltext = Zotero.FullText = new function(){
} }
var itemID = item.id; var itemID = item.id;
var state = this.INDEX_STATE_UNINDEXED;
switch (item.attachmentContentType) { switch (item.attachmentContentType) {
// Use pages for PDFs // Use pages for PDFs
case 'application/pdf': case 'application/pdf':
var pages = yield this.getPages(itemID); var o = yield this.getPages(itemID);
if (pages) { if (o) {
var indexedPages = pages.indexedPages; var stats = {
var totalPages = pages.total; indexed: o.indexedPages,
total: o.total
if (!totalPages && !indexedPages) { };
var status = this.INDEX_STATE_UNAVAILABLE;
}
else if (!indexedPages) {
var status = this.INDEX_STATE_UNINDEXED;
}
else if (indexedPages < totalPages) {
var status = this.INDEX_STATE_PARTIAL;
}
else {
var status = this.INDEX_STATE_INDEXED;
}
}
else {
var status = this.INDEX_STATE_UNINDEXED;
} }
break; break;
// Use chars
default: default:
var chars = yield getChars(itemID); var o = yield getChars(itemID);
if (chars) { if (o) {
var indexedChars = chars.indexedChars; var stats = {
var totalChars = chars.total; indexed: o.indexedChars,
total: o.total
if (!totalChars && !indexedChars) { };
var status = this.INDEX_STATE_UNAVAILABLE;
}
else if (!indexedChars) {
var status = this.INDEX_STATE_UNINDEXED;
}
else if (indexedChars < totalChars) {
var status = this.INDEX_STATE_PARTIAL;
}
else {
var status = this.INDEX_STATE_INDEXED;
}
}
else {
var status = this.INDEX_STATE_UNINDEXED;
} }
} }
return status;
if (stats) {
if (!stats.total && !stats.indexed) {
let queued = false;
try {
queued = yield OS.File.exists(this.getItemProcessorCacheFile(item).path);
}
catch (e) {
Zotero.logError(e);
}
state = queued ? this.INDEX_STATE_QUEUED : this.INDEX_STATE_UNAVAILABLE;
}
else if (!stats.indexed) {
state = this.INDEX_STATE_UNINDEXED;
}
else if (stats.indexed < stats.total) {
state = this.INDEX_STATE_PARTIAL;
}
else {
state = this.INDEX_STATE_INDEXED;
}
}
return state;
}); });
@ -1625,6 +1625,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
case this.INDEX_STATE_UNAVAILABLE: case this.INDEX_STATE_UNAVAILABLE:
case this.INDEX_STATE_UNINDEXED: case this.INDEX_STATE_UNINDEXED:
case this.INDEX_STATE_PARTIAL: case this.INDEX_STATE_PARTIAL:
case this.INDEX_STATE_QUEUED:
// TODO: automatically reindex already-indexed attachments? // TODO: automatically reindex already-indexed attachments?
case this.INDEX_STATE_INDEXED: case this.INDEX_STATE_INDEXED:

View File

@ -757,6 +757,7 @@ searchConditions.annotation = Annotation
fulltext.indexState.indexed = Indexed fulltext.indexState.indexed = Indexed
fulltext.indexState.unavailable = Unknown fulltext.indexState.unavailable = Unknown
fulltext.indexState.partial = Partial fulltext.indexState.partial = Partial
fulltext.indexState.queued = Queued
exportOptions.exportNotes = Export Notes exportOptions.exportNotes = Export Notes
exportOptions.exportFileData = Export Files exportOptions.exportFileData = Export Files