Don't automatically index full-text content in Item::attachmentText
Indexing starts a transaction, which will cause `.attachmentText` to hang if accessed within another transaction. If a caller wants to make sure it has attachment text, it should index items first outside a transaction.
This commit is contained in:
parent
6aa401bceb
commit
58f5150583
1 changed files with 7 additions and 17 deletions
|
@ -3538,26 +3538,16 @@ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentText', {
|
||||||
|
|
||||||
var str;
|
var str;
|
||||||
if (Zotero.Fulltext.isCachedMIMEType(contentType)) {
|
if (Zotero.Fulltext.isCachedMIMEType(contentType)) {
|
||||||
var reindex = false;
|
|
||||||
|
|
||||||
if (!cacheFile.exists()) {
|
if (!cacheFile.exists()) {
|
||||||
Zotero.debug("Regenerating item " + this.id + " full-text cache file");
|
Zotero.debug(`Cache file doesn't exist for item ${this.libraryKey}-- returning empty .attachmentText`);
|
||||||
reindex = true;
|
|
||||||
}
|
|
||||||
// Fully index item if it's not yet
|
|
||||||
else if (!(yield Zotero.Fulltext.isFullyIndexed(this))) {
|
|
||||||
Zotero.debug("Item " + this.id + " is not fully indexed -- caching now");
|
|
||||||
reindex = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reindex) {
|
|
||||||
yield Zotero.Fulltext.indexItems(this.id, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cacheFile.exists()) {
|
|
||||||
Zotero.debug("Cache file doesn't exist after indexing -- returning empty .attachmentText");
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
// Return empty string if not fully indexed
|
||||||
|
if (!(yield Zotero.Fulltext.isFullyIndexed(this))) {
|
||||||
|
Zotero.debug("Item " + this.libraryKey + " is not fully indexed -- returning empty .attachmentText");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
str = yield Zotero.File.getContentsAsync(cacheFile);
|
str = yield Zotero.File.getContentsAsync(cacheFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue