From 45968375d8f7c333a1cac640937b964a473de997 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 23 Mar 2021 03:11:57 -0400 Subject: [PATCH] Return sooner in _checkForUpdatedFile() on SYNC_STATE_TO_UPLOAD Before file.stat() instead of after, though it probably doesn't really matter because the file is already open, which makes the stat call much faster --- .../zotero/xpcom/storage/storageLocal.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index 4b50b767be..e8c3a9d044 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -332,6 +332,17 @@ Zotero.Sync.Storage.Local = { try { file = yield OS.File.open(path); + + // If file is already marked for upload, skip check. Even if the file was changed + // both locally and remotely, conflicts are checked at upload time, so we don't need + // to worry about it here. + // + // This is after open() so that a missing file is properly marked for download. + if (item.attachmentSyncState == this.SYNC_STATE_TO_UPLOAD) { + Zotero.debug("File is already marked for upload"); + return false; + } + let info = yield file.stat(); //Zotero.debug("Memory usage: " + memmgr.resident); @@ -343,14 +354,6 @@ Zotero.Sync.Storage.Local = { fmtime = 0; } - // If file is already marked for upload, skip check. Even if the file was changed - // both locally and remotely, conflicts are checked at upload time, so we don't need - // to worry about it here. - if (item.attachmentSyncState == this.SYNC_STATE_TO_UPLOAD) { - Zotero.debug("File is already marked for upload"); - return false; - } - //Zotero.debug("Stored mtime is " + attachmentData.mtime); //Zotero.debug("File mtime is " + fmtime);