From e1986b460e6a38c191c87229f77019ad174e2248 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 14 May 2017 05:06:37 -0400 Subject: [PATCH] Fix failed export due to missing attachment path --- .../zotero/xpcom/translation/translate_item.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 03cd5432b..2b4a3021e 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -792,9 +792,16 @@ Zotero.Translate.ItemGetter.prototype = { var exportDir = this._exportFileDirectory; // Add path and filename if not an internet link - var attachFile = Zotero.File.pathToFile(attachmentArray.localPath); + let attachFile; + if (attachmentArray.localPath) { + attachFile = Zotero.File.pathToFile(attachmentArray.localPath); + } + else { + Zotero.logError(`Path doesn't exist for attachment ${attachment.libraryKey} ` + + '-- not exporting file'); + } // TODO: Make async, but that will require translator changes - if (attachFile.exists()) { + if (attachFile && attachFile.exists()) { attachmentArray.defaultPath = "files/" + attachment.id + "/" + attachFile.leafName; attachmentArray.filename = attachFile.leafName;