Fix WebDAV test failure

This commit is contained in:
Dan Stillman 2016-01-07 16:38:05 -05:00
parent 739365fd28
commit 4a5de628ce
3 changed files with 17 additions and 10 deletions

View File

@ -539,7 +539,8 @@ Zotero.Sync.Storage.Local = {
* @param {Boolean} [updateItem=FALSE] - Mark attachment item as unsynced * @param {Boolean} [updateItem=FALSE] - Mark attachment item as unsynced
*/ */
setSyncedModificationTime: Zotero.Promise.coroutine(function* (itemID, mtime, updateItem) { 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 Components.utils.reportError("Invalid file mod time " + mtime
+ " in Zotero.Storage.setSyncedModificationTime()"); + " in Zotero.Storage.setSyncedModificationTime()");
mtime = 0; mtime = 0;

View File

@ -1188,7 +1188,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
yield this._deleteStorageFiles([item.key + ".prop"]).catch(function (e) { yield this._deleteStorageFiles([item.key + ".prop"]).catch(function (e) {
Zotero.logError(e); Zotero.logError(e);
}); });
throw new Error(Zotero.Sync.Storage.WebDAV.defaultError); throw new Error(Zotero.Sync.Storage.Mode.WebDAV.defaultError);
} }
return { mtime, md5 }; return { mtime, md5 };

View File

@ -461,21 +461,27 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () {
item.synced = true; item.synced = true;
yield item.saveTx(); yield item.saveTx();
var syncedModTime = Date.now() - 10000;
var syncedHash = "3a2f092dd62178eb8bbfda42e07e64da";
yield Zotero.DB.executeTransaction(function* () { yield Zotero.DB.executeTransaction(function* () {
// Set an mtime in the past // Set an mtime in the past
yield Zotero.Sync.Storage.Local.setSyncedModificationTime( yield Zotero.Sync.Storage.Local.setSyncedModificationTime(item.id, syncedModTime);
item.id,
new Date(Date.now() - 10000)
);
// And a different hash // And a different hash
yield Zotero.Sync.Storage.Local.setSyncedHash( yield Zotero.Sync.Storage.Local.setSyncedHash(item.id, syncedHash);
item.id, "3a2f092dd62178eb8bbfda42e07e64da"
);
}); });
var mtime = yield item.attachmentModificationTime; var mtime = yield item.attachmentModificationTime;
var hash = yield item.attachmentHash; 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({ setResponse({
method: "DELETE", method: "DELETE",
url: `zotero/${item.key}.prop`, url: `zotero/${item.key}.prop`,
@ -493,7 +499,7 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () {
}); });
var result = yield engine.start(); var result = yield engine.start();
assertRequestCount(3); assertRequestCount(4);
assert.isTrue(result.localChanges); assert.isTrue(result.localChanges);
assert.isTrue(result.remoteChanges); assert.isTrue(result.remoteChanges);