From 9ea56705a054b20f278c00d4b40ab89efbd1e1cc Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 9 Jul 2024 11:54:08 -0400 Subject: [PATCH] Don't change title when renaming from parent metadata (#4363) --- chrome/content/zotero/zoteroPane.js | 8 -------- test/tests/zoteroPaneTest.js | 19 ++----------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 0323bd14c2..9d260b6b6f 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -5672,7 +5672,6 @@ var ZoteroPane = new function() if (ext) { newName = newName + ext[0]; } - let origFilenameNoExt = origFilename.replace(extRE, '') var renamed = await item.renameAttachmentFile(newName, false, true); if (renamed !== true) { @@ -5680,13 +5679,6 @@ var ZoteroPane = new function() continue; } - // If the attachment title matched the filename, change it now - let origTitle = item.getField('title'); - if (origTitle == origFilename || origTitle == origFilenameNoExt) { - item.setField('title', newName); - await item.saveTx(); - } - let str = await document.l10n.formatValue('file-renaming-file-renamed-to', { filename: newName }); progressWin.addLines(str, item.getItemTypeIconName()); progressWin.show(); diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index 274de09b46..7628b5fb24 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -671,7 +671,7 @@ describe("ZoteroPane", function() { assert.equal(attachment.getField('title'), 'Image') }); - it("should change attachment title if the same as filename", async function () { + it("should not change attachment title even if the same as filename", async function () { var item = createUnsavedDataObject('item'); item.setField('title', 'Title'); await item.saveTx(); @@ -683,22 +683,7 @@ describe("ZoteroPane", function() { await zp.renameSelectedAttachmentsFromParents(); assert.equal(attachment.attachmentFilename, 'Title.png'); - assert.equal(attachment.getField('title'), 'Title.png') - }); - - it("should change attachment title if the same as filename without extension", async function () { - var item = createUnsavedDataObject('item'); - item.setField('title', 'Title'); - await item.saveTx(); - - var attachment = await importFileAttachment('test.png', { parentItemID: item.id }); - attachment.setField('title', 'test'); - await attachment.saveTx(); - await zp.selectItem(attachment.id); - - await zp.renameSelectedAttachmentsFromParents(); - assert.equal(attachment.attachmentFilename, 'Title.png'); - assert.equal(attachment.getField('title'), 'Title.png') + assert.equal(attachment.getField('title'), 'test.png') }); });