From 861d5787d8bdd2bfb05598a42713f7e60b6a26ff Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 20 May 2021 03:10:31 -0400 Subject: [PATCH] Mendeley online import: Fix error if downloaded file doesn't exist If a file attached to an item with a URL wasn't found in the temp directory, it would trigger an error that stopped the sync. (I'm not sure how a file wouldn't exist.) --- .../content/zotero/import/mendeley/mendeleyImport.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/import/mendeley/mendeleyImport.js b/chrome/content/zotero/import/mendeley/mendeleyImport.js index a70ee386f4..b7448cfbd7 100644 --- a/chrome/content/zotero/import/mendeley/mendeleyImport.js +++ b/chrome/content/zotero/import/mendeley/mendeleyImport.js @@ -1399,7 +1399,7 @@ Zotero_Import_Mendeley.prototype._saveFilesAndAnnotations = async function (file contentType: file.contentType }; // If we're not set to link files or file is in Mendeley downloads folder, import it - if (!this._linkFiles || this._isDownloadedFile(path)) { + if (!this._linkFiles || this._isDownloadedFile(path) || this._isTempDownloadedFile(path)) { if (file.url) { options.title = file.title; options.url = file.url; @@ -1463,10 +1463,14 @@ Zotero_Import_Mendeley.prototype._isDownloadedFile = function (path) { return parentDir.endsWith(OS.Path.join('Application Support', 'Mendeley Desktop', 'Downloaded')) || parentDir.endsWith(OS.Path.join('Local', 'Mendeley Ltd', 'Mendeley Desktop', 'Downloaded')) || parentDir.endsWith(OS.Path.join('Local', 'Mendeley Ltd.', 'Mendeley Desktop', 'Downloaded')) - || parentDir.endsWith(OS.Path.join('data', 'Mendeley Ltd.', 'Mendeley Desktop', 'Downloaded')) - || parentDir.startsWith(OS.Path.join(Zotero.getTempDirectory().path, 'mendeley-online-import')); // Mendeley Online Importer + || parentDir.endsWith(OS.Path.join('data', 'Mendeley Ltd.', 'Mendeley Desktop', 'Downloaded')); } +Zotero_Import_Mendeley.prototype._isTempDownloadedFile = function (path) { + var parentDir = OS.Path.dirname(path); + return parentDir.startsWith(OS.Path.join(Zotero.getTempDirectory().path, 'mendeley-online-import')); +}; + /** * Get the path to use for a file that exists, or false if none *