From f5010ce76449d24f2727442bf93a75974ad0c112 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 27 Aug 2025 03:04:40 -0400 Subject: [PATCH] Don't update file mod time to force sync upload when renaming We've always done this, but it's no longer necessary: - If a file exists locally when a remote filename change comes in, we now rename the local file. - If a file doesn't exist locally and it's a single file, we save the file with the new filename on the next file download. - If a file doesn't exist locally and it's an old multi-file snapshot, we now try to find the primary HTML file and rename it. --- chrome/content/zotero/xpcom/data/item.js | 26 ------------------------ 1 file changed, 26 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 43b617100d..570ca6abad 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2906,9 +2906,6 @@ Zotero.Item.prototype.renameAttachmentFile = async function (newName, overwrite try { let origName = PathUtils.filename(origPath); - if (this.isStoredFileAttachment()) { - var origModDate = (await OS.File.stat(origPath)).lastModificationDate; - } // No change if (origName === newName) { @@ -2916,13 +2913,6 @@ Zotero.Item.prototype.renameAttachmentFile = async function (newName, overwrite return true; } - // Update mod time and clear hash so the file syncs - // TODO: use an integer counter instead of mod time for change detection - // Update mod time first, because it may fail for read-only files on Windows - if (this.isStoredFileAttachment()) { - await OS.File.setDates(origPath, null, null); - } - newName = await Zotero.File.rename( origPath, newName, @@ -2938,26 +2928,10 @@ Zotero.Item.prototype.renameAttachmentFile = async function (newName, overwrite await this.relinkAttachmentFile(destPath); - if (this.isStoredFileAttachment()) { - this.attachmentSyncedHash = null; - this.attachmentSyncState = "to_upload"; - await this.saveTx({ skipAll: true }); - } - return true; } catch (e) { Zotero.logError(e); - - // Restore original modification date in case we managed to change it - if (this.isStoredFileAttachment()) { - try { - OS.File.setDates(origPath, null, origModDate); - } catch (e) { - Zotero.debug(e, 2); - } - } - return -2; } };