From a3f5ead9876b5ae24b185d87a38e37edb78d32a1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 22 Oct 2016 15:22:56 -0400 Subject: [PATCH] Fix file renaming and same-dir relinking (broken by 79baac3158) --- chrome/content/zotero/xpcom/data/item.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 4dd8a8ce19..e0b9791ed8 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2555,11 +2555,14 @@ Zotero.Item.prototype.relinkAttachmentFile = Zotero.Promise.coroutine(function* yield OS.File.remove(newPath + ".bak"); } } - // Rename file to filtered name if necessary - else if (fileName != newName) { + else { newPath = OS.Path.join(OS.Path.dirname(path), newName); - Zotero.debug("Renaming file '" + fileName + "' to '" + newName + "'"); - OS.File.move(path, newPath, { noOverwrite: true }); + + // Rename file to filtered name if necessary + if (fileName != newName) { + Zotero.debug("Renaming file '" + fileName + "' to '" + newName + "'"); + yield OS.File.move(path, newPath, { noOverwrite: true }); + } } this.attachmentPath = newPath;