Address file import bugs
I don't know why why, but wbp.saveDocument() destroys the document object which is passed into it. This means that further access of the document is impossible and raises errors, which we were not handling properly and not returning on attachment saving. I've added error handling and changed removed code which tries to access the document after the Zotero.Utilities.Internal.saveDocument() call. Addresses https://forums.zotero.org/discussion/64745/5-0-beta-apparently-stuck-at-saving-to
This commit is contained in:
parent
406f50a3fd
commit
5818935a32
1 changed files with 12 additions and 5 deletions
|
@ -277,8 +277,14 @@ Zotero.Attachments = new function(){
|
|||
saveOptions
|
||||
})
|
||||
.then(function (attachmentItem) {
|
||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||
deferred.resolve(attachmentItem);
|
||||
})
|
||||
.catch(function(e) {
|
||||
Zotero.logError(e);
|
||||
deferred.reject();
|
||||
})
|
||||
.finally(function() {
|
||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||
});
|
||||
},
|
||||
undefined,
|
||||
|
@ -586,7 +592,7 @@ Zotero.Attachments = new function(){
|
|||
}
|
||||
|
||||
if (contentType === 'text/html' || contentType === 'application/xhtml+xml') {
|
||||
Zotero.debug('Saving document with saveURI()');
|
||||
Zotero.debug('Saving document with saveDocument()');
|
||||
yield Zotero.Utilities.Internal.saveDocument(document, tmpFile.path);
|
||||
}
|
||||
else {
|
||||
|
@ -670,9 +676,10 @@ Zotero.Attachments = new function(){
|
|||
}, 1000);
|
||||
}
|
||||
else if (Zotero.MIME.isTextType(contentType)) {
|
||||
// Index document immediately, so that browser object can't
|
||||
// be removed before indexing completes
|
||||
yield Zotero.Fulltext.indexDocument(document, attachmentItem.id);
|
||||
// wbp.saveDocument consumes the document context (in Zotero.Utilities.Internal.saveDocument)
|
||||
// Seems like a mozilla bug, but nothing on bugtracker.
|
||||
// Either way, we don't rely on Zotero.Fulltext.indexDocument here anymore
|
||||
yield Zotero.Fulltext.indexItems(attachmentItem.id, true, true);
|
||||
}
|
||||
|
||||
return attachmentItem;
|
||||
|
|
Loading…
Add table
Reference in a new issue