diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index d98a93488..d261b22e9 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -539,7 +539,8 @@ Zotero.Sync.Storage.Local = { * @param {Boolean} [updateItem=FALSE] - Mark attachment item as unsynced */ setSyncedModificationTime: Zotero.Promise.coroutine(function* (itemID, mtime, updateItem) { - if (mtime < 0) { + mtime = parseInt(mtime) + if (isNaN(mtime) || mtime < 0) { Components.utils.reportError("Invalid file mod time " + mtime + " in Zotero.Storage.setSyncedModificationTime()"); mtime = 0; diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index c04bf9300..31fe47eed 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -1188,7 +1188,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { yield this._deleteStorageFiles([item.key + ".prop"]).catch(function (e) { Zotero.logError(e); }); - throw new Error(Zotero.Sync.Storage.WebDAV.defaultError); + throw new Error(Zotero.Sync.Storage.Mode.WebDAV.defaultError); } return { mtime, md5 }; diff --git a/test/tests/webdavTest.js b/test/tests/webdavTest.js index 98d2bc6c0..b894a784c 100644 --- a/test/tests/webdavTest.js +++ b/test/tests/webdavTest.js @@ -461,21 +461,27 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () { item.synced = true; yield item.saveTx(); + var syncedModTime = Date.now() - 10000; + var syncedHash = "3a2f092dd62178eb8bbfda42e07e64da"; + yield Zotero.DB.executeTransaction(function* () { // Set an mtime in the past - yield Zotero.Sync.Storage.Local.setSyncedModificationTime( - item.id, - new Date(Date.now() - 10000) - ); + yield Zotero.Sync.Storage.Local.setSyncedModificationTime(item.id, syncedModTime); // And a different hash - yield Zotero.Sync.Storage.Local.setSyncedHash( - item.id, "3a2f092dd62178eb8bbfda42e07e64da" - ); + yield Zotero.Sync.Storage.Local.setSyncedHash(item.id, syncedHash); }); var mtime = yield item.attachmentModificationTime; var hash = yield item.attachmentHash; + setResponse({ + method: "GET", + url: `zotero/${item.key}.prop`, + text: '' + + `${syncedModTime}` + + `${syncedHash}` + + '' + }); setResponse({ method: "DELETE", url: `zotero/${item.key}.prop`, @@ -493,7 +499,7 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () { }); var result = yield engine.start(); - assertRequestCount(3); + assertRequestCount(4); assert.isTrue(result.localChanges); assert.isTrue(result.remoteChanges);