Fix "Cannot edit [object] in library [id]" error message resulting from remote deletions being logged as local deletions
This commit is contained in:
parent
75ae355005
commit
94f53f70f9
|
@ -118,7 +118,7 @@ Zotero.Sync = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Date} lastSyncDate JS Date object
|
* @param {Date} lastSyncDate JS Date object
|
||||||
* @param {Zotero.Sync.Server.ObjectKeySet}
|
* @param {Zotero.Sync.Server.ObjectKeySet}
|
||||||
* @return TRUE if found, FALSE if none, or -1 if last sync time is before start of log
|
* @return TRUE if found, FALSE if none, or -1 if last sync time is before start of log
|
||||||
|
@ -170,6 +170,8 @@ Zotero.Sync = new function() {
|
||||||
for (var type in keys) {
|
for (var type in keys) {
|
||||||
objectKeySet.addLibraryKeyPairs(type, keys[type]);
|
objectKeySet.addLibraryKeyPairs(type, keys[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,7 +282,11 @@ Zotero.Sync.ObjectKeySet.prototype.hasLibraryKey = function (type, libraryID, ke
|
||||||
libraryID = 0;
|
libraryID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this[types] && this[types][libraryID] && this[types][libraryID][key];
|
if (this[types] && this[types][libraryID] && this[types][libraryID][key]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,7 +318,6 @@ Zotero.Sync.EventListener = new function () {
|
||||||
|
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.ignoreDeletions = ignoreDeletions;
|
this.ignoreDeletions = ignoreDeletions;
|
||||||
this.unignoreDeletions = unignoreDeletions;
|
|
||||||
this.notify = notify;
|
this.notify = notify;
|
||||||
|
|
||||||
var _deleteBlacklist = {};
|
var _deleteBlacklist = {};
|
||||||
|
@ -343,22 +348,8 @@ Zotero.Sync.EventListener = new function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.resetIgnored = function () {
|
||||||
/**
|
_deleteBlacklist = {};
|
||||||
* Remove objects blacklisted from the sync delete log
|
|
||||||
*/
|
|
||||||
function unignoreDeletions(type, ids) {
|
|
||||||
if (!Zotero.Sync.syncObjects[type]) {
|
|
||||||
throw ("Invalid type '" + type +
|
|
||||||
"' in Zotero.Sync.EventListener.ignoreDeletions()");
|
|
||||||
}
|
|
||||||
|
|
||||||
ids = Zotero.flattenArguments(ids);
|
|
||||||
for each(var id in ids) {
|
|
||||||
if (_deleteBlacklist[type][id]) {
|
|
||||||
delete _deleteBlacklist[type][id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,10 +379,11 @@ Zotero.Sync.EventListener = new function () {
|
||||||
var ts = Zotero.Date.getUnixTimestamp();
|
var ts = Zotero.Date.getUnixTimestamp();
|
||||||
|
|
||||||
for (var i=0, len=ids.length; i<len; i++) {
|
for (var i=0, len=ids.length; i<len; i++) {
|
||||||
if (_deleteBlacklist[ids[i]]) {
|
if (_deleteBlacklist[type] && _deleteBlacklist[type][ids[i]]) {
|
||||||
Zotero.debug("Not logging blacklisted '"
|
Zotero.debug("Not logging blacklisted '"
|
||||||
+ type + "' id " + ids[i]
|
+ type + "' id " + ids[i]
|
||||||
+ " in Zotero.Sync.EventListener.notify()", 4);
|
+ " in Zotero.Sync.EventListener.notify()", 4);
|
||||||
|
delete _deleteBlacklist[type][ids[i]];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1056,6 +1048,7 @@ Zotero.Sync.Server = new function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Zotero.reloadDataObjects();
|
Zotero.reloadDataObjects();
|
||||||
|
Zotero.Sync.EventListener.resetIgnored();
|
||||||
_syncInProgress = false;
|
_syncInProgress = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1783,6 +1776,7 @@ Zotero.Sync.Server = new function () {
|
||||||
_syncInProgress = false;
|
_syncInProgress = false;
|
||||||
Zotero.DB.rollbackAllTransactions();
|
Zotero.DB.rollbackAllTransactions();
|
||||||
Zotero.reloadDataObjects();
|
Zotero.reloadDataObjects();
|
||||||
|
Zotero.Sync.EventListener.resetIgnored();
|
||||||
|
|
||||||
if (_sessionID && _sessionLock) {
|
if (_sessionID && _sessionLock) {
|
||||||
Zotero.Sync.Server.unlock()
|
Zotero.Sync.Server.unlock()
|
||||||
|
@ -2492,12 +2486,10 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
if (children.length) {
|
if (children.length) {
|
||||||
Zotero.Sync.EventListener.ignoreDeletions('item', children);
|
Zotero.Sync.EventListener.ignoreDeletions('item', children);
|
||||||
Zotero.Items.erase(children);
|
Zotero.Items.erase(children);
|
||||||
Zotero.Sync.EventListener.unignoreDeletions('item', children);
|
|
||||||
}
|
}
|
||||||
if (parents.length) {
|
if (parents.length) {
|
||||||
Zotero.Sync.EventListener.ignoreDeletions('item', parents);
|
Zotero.Sync.EventListener.ignoreDeletions('item', parents);
|
||||||
Zotero.Items.erase(parents);
|
Zotero.Items.erase(parents);
|
||||||
Zotero.Sync.EventListener.unignoreDeletions('item', parents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlock dateModified for deleted collections
|
// Unlock dateModified for deleted collections
|
||||||
|
@ -2509,7 +2501,6 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
else {
|
else {
|
||||||
Zotero.Sync.EventListener.ignoreDeletions(type, toDelete);
|
Zotero.Sync.EventListener.ignoreDeletions(type, toDelete);
|
||||||
Zotero[Types].erase(toDelete);
|
Zotero[Types].erase(toDelete);
|
||||||
Zotero.Sync.EventListener.unignoreDeletions(type, toDelete);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user