Don't retry cancelled conflicts immediately
If other items were saved in the same batch, the conflict resolution window could reappear immediately after cancelling it.
This commit is contained in:
parent
c146adce38
commit
295e9f3ecf
|
@ -911,6 +911,17 @@ Zotero.Sync.Data.Local = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Zotero.debug("Conflict resolution was cancelled", 2);
|
||||||
|
for (let conflict of conflicts) {
|
||||||
|
results.push({
|
||||||
|
// Use key from either, in case one side is deleted
|
||||||
|
key: conflict.left.key || conflict.right.key,
|
||||||
|
processed: false,
|
||||||
|
retry: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let processed = 0;
|
let processed = 0;
|
||||||
|
|
|
@ -1359,6 +1359,105 @@ describe("Zotero.Sync.Data.Engine", function () {
|
||||||
assert.isFalse(Zotero.Items.exists(itemID1));
|
assert.isFalse(Zotero.Items.exists(itemID1));
|
||||||
assert.isTrue(Zotero.Items.exists(itemID2));
|
assert.isTrue(Zotero.Items.exists(itemID2));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should handle cancellation of conflict resolution window", function* () {
|
||||||
|
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||||
|
yield Zotero.Libraries.setVersion(userLibraryID, 5);
|
||||||
|
({ engine, client, caller } = yield setup());
|
||||||
|
|
||||||
|
var item = yield createDataObject('item');
|
||||||
|
var itemID = yield item.saveTx();
|
||||||
|
var itemKey = item.key;
|
||||||
|
|
||||||
|
var headers = {
|
||||||
|
"Last-Modified-Version": 6
|
||||||
|
};
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/settings?since=5",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {}
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/collections?format=versions&since=5",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {}
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/searches?format=versions&since=5",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {}
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/items/top?format=versions&since=5&includeTrashed=1",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {
|
||||||
|
AAAAAAAA: 6,
|
||||||
|
[itemKey]: 6
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: `users/1/items?format=json&itemKey=AAAAAAAA%2C${itemKey}&includeTrashed=1`,
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: [
|
||||||
|
makeItemJSON({
|
||||||
|
key: "AAAAAAAA",
|
||||||
|
version: 6,
|
||||||
|
itemType: "book",
|
||||||
|
title: "B"
|
||||||
|
}),
|
||||||
|
makeItemJSON({
|
||||||
|
key: itemKey,
|
||||||
|
version: 6,
|
||||||
|
itemType: "book",
|
||||||
|
title: "B"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/items?format=versions&since=5&includeTrashed=1",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {}
|
||||||
|
});
|
||||||
|
setResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "users/1/deleted?since=5",
|
||||||
|
status: 200,
|
||||||
|
headers: headers,
|
||||||
|
json: {
|
||||||
|
settings: [],
|
||||||
|
collections: [],
|
||||||
|
searches: [],
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
waitForWindow('chrome://zotero/content/merge.xul', function (dialog) {
|
||||||
|
var doc = dialog.document;
|
||||||
|
var wizard = doc.documentElement;
|
||||||
|
wizard.getButton('cancel').click();
|
||||||
|
})
|
||||||
|
yield engine._startDownload();
|
||||||
|
|
||||||
|
// Non-conflicted item should be saved
|
||||||
|
assert.ok(Zotero.Items.getIDFromLibraryAndKey(userLibraryID, "AAAAAAAA"));
|
||||||
|
|
||||||
|
// Conflicted item should be skipped and in queue
|
||||||
|
assert.isFalse(Zotero.Items.exists(itemID));
|
||||||
|
var keys = yield Zotero.Sync.Data.Local.getObjectsFromSyncQueue('item', userLibraryID);
|
||||||
|
assert.sameMembers(keys, [itemKey]);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#_upgradeCheck()", function () {
|
describe("#_upgradeCheck()", function () {
|
||||||
|
|
|
@ -854,7 +854,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
json.data.note = noteText2;
|
json.data.note = noteText2;
|
||||||
downloadedJSON.push(json);
|
downloadedJSON.push(json);
|
||||||
|
|
||||||
// Delete object locally
|
// Modify local version
|
||||||
obj.setNote(noteText1);
|
obj.setNote(noteText1);
|
||||||
|
|
||||||
waitForWindow('chrome://zotero/content/merge.xul', function (dialog) {
|
waitForWindow('chrome://zotero/content/merge.xul', function (dialog) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user