www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 5818935a321c7fcf152848a6e8617dbc31ed6dbd
parent 406f50a3fdc305fc759b96c68f8d6a7de46e3fa3
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date:   Fri,  7 Apr 2017 14:35:49 +0300

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

Diffstat:
Mchrome/content/zotero/xpcom/attachments.js | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js @@ -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;