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.
This commit is contained in:
Dan Stillman 2025-08-27 03:04:40 -04:00
parent bab0237727
commit f5010ce764

View file

@ -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;
}
};