Fix "attachmentSyncedModificationTime must be a number" sync error
https://forums.zotero.org/discussion/79011/zotero-error-report
This commit is contained in:
parent
4b7cdddb4a
commit
5723683b3b
2 changed files with 56 additions and 5 deletions
|
@ -1065,11 +1065,19 @@ Zotero.Sync.Storage.Local = {
|
||||||
// Local
|
// Local
|
||||||
if (mtime == conflict.left.dateModified) {
|
if (mtime == conflict.left.dateModified) {
|
||||||
syncState = this.SYNC_STATE_FORCE_UPLOAD;
|
syncState = this.SYNC_STATE_FORCE_UPLOAD;
|
||||||
// When local version is chosen, update stored hash (and mtime) to remote values so
|
// When local version is chosen, update stored mtime and hash to remote values
|
||||||
// that upload goes through without 412
|
// so that upload goes through without a 412.
|
||||||
|
//
|
||||||
|
// These sometimes might not be set in the cached JSON (for unclear reasons, but
|
||||||
|
// see https://forums.zotero.org/discussion/79011/zotero-error-report), in which
|
||||||
|
// case we just ignore them and hope that the local version has null values too.
|
||||||
|
if (conflict.right.mtime) {
|
||||||
item.attachmentSyncedModificationTime = conflict.right.mtime;
|
item.attachmentSyncedModificationTime = conflict.right.mtime;
|
||||||
|
}
|
||||||
|
if (conflict.right.md5) {
|
||||||
item.attachmentSyncedHash = conflict.right.md5;
|
item.attachmentSyncedHash = conflict.right.md5;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Remote
|
// Remote
|
||||||
else {
|
else {
|
||||||
syncState = this.SYNC_STATE_FORCE_DOWNLOAD;
|
syncState = this.SYNC_STATE_FORCE_DOWNLOAD;
|
||||||
|
|
|
@ -671,6 +671,49 @@ describe("Zotero.Sync.Storage.Local", function () {
|
||||||
assert.equal(item3.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_FORCE_DOWNLOAD);
|
assert.equal(item3.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_FORCE_DOWNLOAD);
|
||||||
assert.isNull(item3.attachmentSyncedModificationTime);
|
assert.isNull(item3.attachmentSyncedModificationTime);
|
||||||
assert.isNull(item3.attachmentSyncedHash);
|
assert.isNull(item3.attachmentSyncedHash);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it("should handle attachment conflicts with no remote mtime/md5", function* () {
|
||||||
|
var libraryID = Zotero.Libraries.userLibraryID;
|
||||||
|
|
||||||
|
var item1 = yield importFileAttachment('test.png');
|
||||||
|
item1.version = 10;
|
||||||
|
yield item1.saveTx();
|
||||||
|
|
||||||
|
var json1 = item1.toJSON();
|
||||||
|
yield Zotero.Sync.Data.Local.saveCacheObjects('item', libraryID, [json1]);
|
||||||
|
|
||||||
|
item1.attachmentSyncState = "in_conflict";
|
||||||
|
yield item1.saveTx({ skipAll: true });
|
||||||
|
|
||||||
|
var promise = waitForWindow('chrome://zotero/content/merge.xul', async function (dialog) {
|
||||||
|
var doc = dialog.document;
|
||||||
|
var wizard = doc.documentElement;
|
||||||
|
var mergeGroup = wizard.getElementsByTagName('zoteromergegroup')[0];
|
||||||
|
|
||||||
|
// 1 (remote)
|
||||||
|
// Identical, so remote version should be selected
|
||||||
|
assert.equal(mergeGroup.rightpane.getAttribute('selected'), 'true');
|
||||||
|
|
||||||
|
// Select local object
|
||||||
|
mergeGroup.leftpane.click();
|
||||||
|
assert.equal(mergeGroup.leftpane.getAttribute('selected'), 'true');
|
||||||
|
|
||||||
|
if (Zotero.isMac) {
|
||||||
|
assert.isTrue(wizard.getButton('next').hidden);
|
||||||
|
assert.isFalse(wizard.getButton('finish').hidden);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
wizard.getButton('finish').click();
|
||||||
|
});
|
||||||
|
yield Zotero.Sync.Storage.Local.resolveConflicts(libraryID);
|
||||||
|
yield promise;
|
||||||
|
|
||||||
|
assert.equal(item1.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_FORCE_UPLOAD);
|
||||||
|
assert.isNull(item1.attachmentSyncedModificationTime);
|
||||||
|
assert.isNull(item1.attachmentSyncedHash);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue