commit 4a5de628ce9d4118c3f745a177bb1d266111e480
parent 739365fd28103cd2ee7845df37941c990e9b5d12
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 7 Jan 2016 16:38:05 -0500
Fix WebDAV test failure
Diffstat:
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git 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
@@ -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
@@ -461,22 +461,28 @@ 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: '<properties version="1">'
+ + `<mtime>${syncedModTime}</mtime>`
+ + `<hash>${syncedHash}</hash>`
+ + '</properties>'
+ });
+ setResponse({
method: "DELETE",
url: `zotero/${item.key}.prop`,
status: 204
@@ -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);