From a69b55ea96840b748d1a10ebb2777da8a2938f25 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 9 Oct 2026 14:44:50 -0400 Subject: [PATCH] Mark the first request when using Replace Online Library Add a restoreToServer=1 query parameter so we can identify restores server-side if necessary --- chrome/content/zotero/xpcom/sync/syncAPIClient.js | 3 ++- chrome/content/zotero/xpcom/sync/syncEngine.js | 6 ++++-- test/tests/syncEngineTest.js | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js index 2215113090..4296407a30 100644 --- a/chrome/content/zotero/xpcom/sync/syncAPIClient.js +++ b/chrome/content/zotero/xpcom/sync/syncAPIClient.js @@ -825,7 +825,8 @@ Zotero.Sync.APIClient.prototype = { 'sort', 'direction', 'since', - 'sincetime' + 'sincetime', + 'restoreToServer' ]; queryParams = {}; diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index 8e2b10d610..7dc82767d6 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -2045,11 +2045,13 @@ Zotero.Sync.Data.Engine.prototype._restoreToServer = async function () { let ObjectType = Zotero.Utilities.capitalize(objectType); let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType); - // Get all object versions from the API + // Get all object versions from the API, marking the first request so that restores can + // be identified in server logs let results = await this.apiClient.getVersions( this.library.libraryType, this.libraryTypeID, - objectType + objectType, + libraryVersion ? undefined : { restoreToServer: 1 } ); if (libraryVersion && libraryVersion != results.libraryVersion) { throw new Error(remoteUpdatedError diff --git a/test/tests/syncEngineTest.js b/test/tests/syncEngineTest.js index 479dc69d86..24618460af 100644 --- a/test/tests/syncEngineTest.js +++ b/test/tests/syncEngineTest.js @@ -5206,6 +5206,10 @@ describe("Zotero.Sync.Data.Engine", function () { for (let type of types) { let plural = Zotero.DataObjectUtilities.getObjectTypePlural(type); let suffix = type == 'item' ? '&includeTrashed=1' : ''; + // Only the first request of the restore is marked + if (type == types[0]) { + suffix += '&restoreToServer=1'; + } let json = {}; json[objectJSON[type][0].key] = objectJSON[type][0].version;