Fix possible "Parent collection for keyed parent doesn't exist in Zotero.Collection._getParent()" sync error
This commit is contained in:
parent
87e2924984
commit
cf5eb92799
2 changed files with 38 additions and 38 deletions
|
@ -943,7 +943,7 @@ Zotero.Collection.prototype.serialize = function(nested) {
|
||||||
},
|
},
|
||||||
fields: {
|
fields: {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
parent: this.parent,
|
parentKey: this.parentKey,
|
||||||
},
|
},
|
||||||
childCollections: childCollections ? childCollections : [],
|
childCollections: childCollections ? childCollections : [],
|
||||||
childItems: childItems ? childItems : [],
|
childItems: childItems ? childItems : [],
|
||||||
|
|
|
@ -421,12 +421,13 @@ Zotero.Sync.EventListener = new function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
|
var errMsg = Zotero.DB.getLastErrorString();
|
||||||
syncStatement.reset();
|
syncStatement.reset();
|
||||||
if (storageEnabled) {
|
if (storageEnabled) {
|
||||||
storageStatement.reset();
|
storageStatement.reset();
|
||||||
}
|
}
|
||||||
Zotero.DB.rollbackTransaction();
|
Zotero.DB.rollbackTransaction();
|
||||||
throw(Zotero.DB.getLastErrorString());
|
throw (errMsg + " in Zotero.Sync.EventListener.notify()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1841,6 +1842,8 @@ Zotero.Sync.Server.Session = function () {
|
||||||
this.uploadKeys = {};
|
this.uploadKeys = {};
|
||||||
this.uploadKeys.updated = new Zotero.Sync.ObjectKeySet;
|
this.uploadKeys.updated = new Zotero.Sync.ObjectKeySet;
|
||||||
this.uploadKeys.deleted = new Zotero.Sync.ObjectKeySet;
|
this.uploadKeys.deleted = new Zotero.Sync.ObjectKeySet;
|
||||||
|
|
||||||
|
this.suppressWarnings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2078,7 +2081,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
}
|
}
|
||||||
// Mark other types for conflict resolution
|
// Mark other types for conflict resolution
|
||||||
else {
|
else {
|
||||||
var reconcile = false;
|
var skipCR = false;
|
||||||
|
|
||||||
// Skip item if dateModified is the only modified
|
// Skip item if dateModified is the only modified
|
||||||
// field (and no linked creators changed)
|
// field (and no linked creators changed)
|
||||||
|
@ -2127,15 +2130,18 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
remoteObj = 'trashed';
|
remoteObj = 'trashed';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
reconcile = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'collection':
|
case 'collection':
|
||||||
var changed = _mergeCollection(obj, remoteObj, childItemStore);
|
// TODO: move childItemStore to syncSession
|
||||||
|
var changed = _mergeCollection(obj, remoteObj, childItemStore, syncSession);
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
syncSession.removeFromUpdated(obj);
|
syncSession.removeFromUpdated(obj);
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
// The merged collection needs to be saved
|
||||||
|
skipCR = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'tag':
|
case 'tag':
|
||||||
var changed = _mergeTag(obj, remoteObj);
|
var changed = _mergeTag(obj, remoteObj);
|
||||||
|
@ -2145,16 +2151,9 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reconcile) {
|
|
||||||
Zotero.debug(obj);
|
|
||||||
Zotero.debug(remoteObj);
|
|
||||||
var msg = "Reconciliation unimplemented for " + types;
|
|
||||||
alert(msg);
|
|
||||||
throw(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: order reconcile by parent/child?
|
// TODO: order reconcile by parent/child?
|
||||||
|
|
||||||
|
if (!skipCR) {
|
||||||
toReconcile.push([
|
toReconcile.push([
|
||||||
obj,
|
obj,
|
||||||
remoteObj
|
remoteObj
|
||||||
|
@ -2163,6 +2162,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Zotero.debug("Local " + type + " has not changed", 4);
|
Zotero.debug("Local " + type + " has not changed", 4);
|
||||||
}
|
}
|
||||||
|
@ -2641,7 +2641,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _mergeCollection(localObj, remoteObj, childItemStore) {
|
function _mergeCollection(localObj, remoteObj, childItemStore, syncSession) {
|
||||||
var diff = localObj.diff(remoteObj, false, true);
|
var diff = localObj.diff(remoteObj, false, true);
|
||||||
if (!diff) {
|
if (!diff) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2651,8 +2651,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
Zotero.debug(diff);
|
Zotero.debug(diff);
|
||||||
|
|
||||||
// Local is newer
|
// Local is newer
|
||||||
if (diff[0].primary.dateModified >
|
if (diff[0].primary.dateModified > diff[1].primary.dateModified) {
|
||||||
diff[1].primary.dateModified) {
|
|
||||||
var remoteIsTarget = false;
|
var remoteIsTarget = false;
|
||||||
var targetObj = localObj;
|
var targetObj = localObj;
|
||||||
var targetDiff = diff[0];
|
var targetDiff = diff[0];
|
||||||
|
@ -2667,12 +2666,14 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetDiff.fields.name) {
|
if (targetDiff.fields.name) {
|
||||||
|
if (!syncSession.suppressWarnings) {
|
||||||
var msg = _generateAutoChangeMessage(
|
var msg = _generateAutoChangeMessage(
|
||||||
'collection', diff[0].fields.name, diff[1].fields.name, remoteIsTarget
|
'collection', diff[0].fields.name, diff[1].fields.name, remoteIsTarget
|
||||||
);
|
);
|
||||||
// TODO: log rather than alert
|
// TODO: log rather than alert
|
||||||
alert(msg);
|
alert(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for child collections in the other object
|
// Check for child collections in the other object
|
||||||
// that aren't in the target one
|
// that aren't in the target one
|
||||||
|
@ -2692,6 +2693,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
targetObj.childItems = otherDiff.childItems;
|
targetObj.childItems = otherDiff.childItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!syncSession.suppressWarnings) {
|
||||||
var msg = _generateCollectionItemMergeMessage(
|
var msg = _generateCollectionItemMergeMessage(
|
||||||
targetObj.name,
|
targetObj.name,
|
||||||
otherDiff.childItems,
|
otherDiff.childItems,
|
||||||
|
@ -2700,10 +2702,8 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
// TODO: log rather than alert
|
// TODO: log rather than alert
|
||||||
alert(msg);
|
alert(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_removeChildItemsFromCollection(targetObj, childItemStore);
|
|
||||||
|
|
||||||
targetObj.save();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue