From f7e90676608d1b598b9fc85d9f2ed238145a118f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 12 Oct 2018 13:48:06 +0300 Subject: [PATCH] Fix imports with missing attachments not closing progress window. Closes #1583 --- .../content/zotero/xpcom/translation/translate_item.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 0a0ef0feaf..c9fe751858 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -196,9 +196,10 @@ Zotero.Translate.ItemSaver.prototype = { // possible downloads. // // TODO: Separate pref? + var shouldDownloadOAPDF = this.attachmentMode == Zotero.Translate.ItemSaver.ATTACHMENT_MODE_DOWNLOAD + && Zotero.Prefs.get('downloadAssociatedFiles'); var openAccessPDFURLs = new Map(); - if (this.attachmentMode == Zotero.Translate.ItemSaver.ATTACHMENT_MODE_DOWNLOAD - && Zotero.Prefs.get('downloadAssociatedFiles')) { + if (shouldDownloadOAPDF) { for (let item of items) { let jsonItem = jsonByItem.get(item); @@ -239,7 +240,7 @@ Zotero.Translate.ItemSaver.prototype = { parentItemID, function (attachment, progress, error) { // Don't cancel failed primary PDFs until we've tried other methods - if (progress === false && attachment.isPrimaryPDF) { + if (progress === false && attachment.isPrimaryPDF && shouldDownloadOAPDF) { return; } attachmentCallback(...arguments); @@ -252,8 +253,7 @@ Zotero.Translate.ItemSaver.prototype = { // If a translated PDF attachment wasn't saved successfully, either because there wasn't // one or there was but it failed, look for another PDF (if enabled) - if (this.attachmentMode == Zotero.Translate.ItemSaver.ATTACHMENT_MODE_DOWNLOAD - && Zotero.Prefs.get('downloadAssociatedFiles')) { + if (shouldDownloadOAPDF) { for (let item of items) { // Already have a PDF from translation if (itemIDsWithPDFAttachments.has(item.id)) {