mirror of
https://github.com/zotero/zotero.git
synced 2026-10-04 02:31:47 +00:00
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:
parent
bab0237727
commit
f5010ce764
1 changed files with 0 additions and 26 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue