diff --git a/chrome/content/zotero/import/mendeley/mendeleyImport.js b/chrome/content/zotero/import/mendeley/mendeleyImport.js index 22d099c21c..0b54759cd2 100644 --- a/chrome/content/zotero/import/mendeley/mendeleyImport.js +++ b/chrome/content/zotero/import/mendeley/mendeleyImport.js @@ -1410,6 +1410,8 @@ Zotero_Import_Mendeley.prototype._saveFilesAndAnnotations = async function (file // If we're not set to link files or file is in Mendeley downloads folder, import it if (!this._linkFiles || this._isDownloadedFile(path) || this._isTempDownloadedFile(path)) { + options.moveFile = this._isTempDownloadedFile(path); + if (file.url) { options.title = file.title; options.url = file.url; @@ -1480,8 +1482,7 @@ Zotero_Import_Mendeley.prototype._isDownloadedFile = function (path) { } Zotero_Import_Mendeley.prototype._isTempDownloadedFile = function (path) { - var parentDir = OS.Path.dirname(path); - return parentDir.startsWith(OS.Path.join(Zotero.getTempDirectory().path, 'm-api')); + return path.startsWith(OS.Path.join(Zotero.getTempDirectory().path, 'm-api')); }; /** diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 4990674489..681dcbb1ed 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -109,8 +109,14 @@ Zotero.Attachments = new function(){ // Point to copied file newFile = OS.Path.join(destDir, newName); - // Copy file to unique filename, which automatically shortens long filenames - newFile = Zotero.File.copyToUnique(file, newFile); + // Copy or move file to unique filename, which automatically shortens long filenames + if (options.moveFile) { + const newFilePath = yield Zotero.File.moveToUnique(file.path, newFile); + newFile = Zotero.File.pathToFile(newFilePath); + } + else { + newFile = Zotero.File.copyToUnique(file, newFile); + } yield Zotero.File.setNormalFilePermissions(newFile.path); @@ -315,7 +321,12 @@ Zotero.Attachments = new function(){ // Copy single file to new directory if (options.singleFile) { yield this.createDirectoryForItem(attachmentItem); - yield OS.File.copy(file.path, newPath); + if (options.moveFile) { + yield OS.File.move(file.path, newPath); + } + else { + yield OS.File.copy(file.path, newPath); + } } // Copy entire parent directory (for HTML snapshots) else {