diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index cccf1e626..c5bd0dfaf 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -959,7 +959,12 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func ); yield Zotero.DB.executeTransaction(function* () { for (let i = 0; i < toSave.length; i++) { - yield toSave[i].save(); + yield toSave[i].save({ + skipSyncedUpdate: true, + // We want to minimize the times when server writes actually result in local + // updates, but when they do, don't update the user-visible timestamp + skipDateModifiedUpdate: true + }); } this.library.libraryVersion = libraryVersion; yield this.library.save(); diff --git a/test/tests/syncEngineTest.js b/test/tests/syncEngineTest.js index db6abfb91..e5a25d2c0 100644 --- a/test/tests/syncEngineTest.js +++ b/test/tests/syncEngineTest.js @@ -960,18 +960,29 @@ describe("Zotero.Sync.Data.Engine", function () { it("should update local objects with remotely saved version after uploading if necessary", function* () { ({ engine, client, caller } = yield setup()); - var libraryID = Zotero.Libraries.userLibraryID; + var library = Zotero.Libraries.userLibrary; + var libraryID = library.id; var lastLibraryVersion = 5; - yield Zotero.Libraries.setVersion(libraryID, lastLibraryVersion); + library.libraryVersion = lastLibraryVersion; + yield library.saveTx(); var types = Zotero.DataObjectUtilities.getTypes(); var objects = {}; var objectResponseJSON = {}; var objectNames = {}; + var itemDateModified = {}; for (let type of types) { - objects[type] = [yield createDataObject(type, { setTitle: true })]; + objects[type] = [ + yield createDataObject( + type, { setTitle: true, dateModified: '2016-05-21 01:00:00' } + ) + ]; objectNames[type] = {}; objectResponseJSON[type] = objects[type].map(o => o.toResponseJSON()); + if (type == 'item') { + let item = objects[type][0]; + itemDateModified[item.key] = item.dateModified; + } } server.respond(function (req) { @@ -1011,7 +1022,7 @@ describe("Zotero.Sync.Data.Engine", function () { yield engine.start(); - assert.equal(Zotero.Libraries.getVersion(libraryID), lastLibraryVersion); + assert.equal(library.libraryVersion, lastLibraryVersion); for (let type of types) { // Make sure local objects were updated with new metadata and marked as synced assert.lengthOf((yield Zotero.Sync.Data.Local.getUnsynced(type, libraryID)), 0); @@ -1021,6 +1032,9 @@ describe("Zotero.Sync.Data.Engine", function () { let name = objectNames[type][key]; if (type == 'item') { assert.equal(name, o.getField('title')); + + // But Date Modified shouldn't have changed for items + assert.equal(itemDateModified[key], o.dateModified); } else { assert.equal(name, o.name);