diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 64248dfdb..9faf5d97e 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2742,15 +2742,21 @@ Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) { // Ignore if no change // // Note: Just comparing file.leafName to newName isn't reliable - if (file.leafName == dest.leafName) { + if (file.leafName === dest.leafName) { return true; } - if (overwrite) { - dest.remove(false); - } - else if (dest.exists()) { - return -1; + // If old and new names differ only in case, let's bank on this + // just being a case change and not bother checking for existing + // files, since dest.exists() will just show true on a case-insensitive + // filesystem anyway. + if (file.leafName.toLowerCase() != dest.leafName.toLowerCase()) { + if (overwrite) { + dest.remove(false); + } + else if (dest.exists()) { + return -1; + } } file.moveTo(null, newName); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 70bcc4688..da39c09d2 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -3684,9 +3684,9 @@ var ZoteroPane = new function() var parentItemID = item.getSource(); var newName = Zotero.Attachments.getFileBaseNameFromItem(parentItemID); - var ext = file.leafName.match(/[^\.]+$/); + var ext = file.leafName.match(/\.[^\.]+$/); if (ext) { - newName = newName + '.' + ext; + newName = newName + ext; } var renamed = item.renameAttachmentFile(newName);