Fix potential error reconciling changes after 3fbb17a2e6
This commit is contained in:
parent
3fbb17a2e6
commit
32de0d4037
1 changed files with 9 additions and 7 deletions
|
@ -1481,6 +1481,7 @@ Zotero.Sync.Data.Local = {
|
||||||
Zotero.debug(changeset2);
|
Zotero.debug(changeset2);
|
||||||
|
|
||||||
var conflicts = [];
|
var conflicts = [];
|
||||||
|
var matchedLocalChanges = new Set();
|
||||||
|
|
||||||
for (let i = 0; i < changeset1.length; i++) {
|
for (let i = 0; i < changeset1.length; i++) {
|
||||||
for (let j = 0; j < changeset2.length; j++) {
|
for (let j = 0; j < changeset2.length; j++) {
|
||||||
|
@ -1541,7 +1542,7 @@ Zotero.Sync.Data.Local = {
|
||||||
let creators2 = c2.value;
|
let creators2 = c2.value;
|
||||||
if (creators1.length == creators2.length
|
if (creators1.length == creators2.length
|
||||||
&& creators1.every((c, index) => Zotero.Creators.equals(c, creators2[index]))) {
|
&& creators1.every((c, index) => Zotero.Creators.equals(c, creators2[index]))) {
|
||||||
changeset1.splice(i--, 1);
|
matchedLocalChanges.add(i);
|
||||||
changeset2.splice(j--, 1);
|
changeset2.splice(j--, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1549,6 +1550,7 @@ Zotero.Sync.Data.Local = {
|
||||||
|
|
||||||
// Removed on both sides
|
// Removed on both sides
|
||||||
if (c1.op == 'delete' && c2.op == 'delete') {
|
if (c1.op == 'delete' && c2.op == 'delete') {
|
||||||
|
matchedLocalChanges.add(i);
|
||||||
changeset2.splice(j--, 1);
|
changeset2.splice(j--, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1558,7 +1560,7 @@ Zotero.Sync.Data.Local = {
|
||||||
|| (c1.op == 'member-remove' && c2.op == 'member-remove')
|
|| (c1.op == 'member-remove' && c2.op == 'member-remove')
|
||||||
|| (c1.op == 'property-member-add' && c2.op == 'property-member-add')
|
|| (c1.op == 'property-member-add' && c2.op == 'property-member-add')
|
||||||
|| (c1.op == 'property-member-remove' && c2.op == 'property-member-remove')) {
|
|| (c1.op == 'property-member-remove' && c2.op == 'property-member-remove')) {
|
||||||
changeset1.splice(i--, 1);
|
matchedLocalChanges.add(i);
|
||||||
changeset2.splice(j--, 1);
|
changeset2.splice(j--, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1566,7 +1568,7 @@ Zotero.Sync.Data.Local = {
|
||||||
// If both sides have values, see if they're the same, and if so remove the
|
// If both sides have values, see if they're the same, and if so remove the
|
||||||
// second one
|
// second one
|
||||||
if (c1.op != 'delete' && c2.op != 'delete' && c1.value === c2.value) {
|
if (c1.op != 'delete' && c2.op != 'delete' && c1.value === c2.value) {
|
||||||
changeset1.splice(i--, 1);
|
matchedLocalChanges.add(i);
|
||||||
changeset2.splice(j--, 1);
|
changeset2.splice(j--, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1579,7 +1581,7 @@ Zotero.Sync.Data.Local = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conflict
|
// Conflict
|
||||||
changeset1.splice(i--, 1);
|
matchedLocalChanges.add(i);
|
||||||
changeset2.splice(j--, 1);
|
changeset2.splice(j--, 1);
|
||||||
conflicts.push([c1, c2]);
|
conflicts.push([c1, c2]);
|
||||||
}
|
}
|
||||||
|
@ -1588,9 +1590,9 @@ Zotero.Sync.Data.Local = {
|
||||||
return {
|
return {
|
||||||
changes: changeset2,
|
changes: changeset2,
|
||||||
conflicts,
|
conflicts,
|
||||||
// If there were unique local changes, we need to know that so the item can be kept as
|
// If there were local changes that weren't made remotely as well, the item needs to be
|
||||||
// unsynced
|
// kept as unsynced
|
||||||
localChanged: !!changeset1.length
|
localChanged: changeset1.length > matchedLocalChanges.size
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue