www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 94f53f70f914ee28b9a99b65c6e95c57eb720cd3
parent 75ae35500565fc55d007c44555eb7fa6d5f69047
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 19 Aug 2009 07:16:19 +0000

Fix "Cannot edit [object] in library [id]" error message resulting from remote deletions being logged as local deletions


Diffstat:
Mchrome/content/zotero/xpcom/sync.js | 37++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js @@ -118,7 +118,7 @@ Zotero.Sync = new function() { } - /** + /** * @param {Date} lastSyncDate JS Date object * @param {Zotero.Sync.Server.ObjectKeySet} * @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) { objectKeySet.addLibraryKeyPairs(type, keys[type]); } + + return true; } @@ -280,7 +282,11 @@ Zotero.Sync.ObjectKeySet.prototype.hasLibraryKey = function (type, libraryID, ke 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.ignoreDeletions = ignoreDeletions; - this.unignoreDeletions = unignoreDeletions; this.notify = notify; var _deleteBlacklist = {}; @@ -343,22 +348,8 @@ Zotero.Sync.EventListener = new function () { } } - - /** - * 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]; - } - } + this.resetIgnored = function () { + _deleteBlacklist = {}; } @@ -388,10 +379,11 @@ Zotero.Sync.EventListener = new function () { var ts = Zotero.Date.getUnixTimestamp(); 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 '" + type + "' id " + ids[i] + " in Zotero.Sync.EventListener.notify()", 4); + delete _deleteBlacklist[type][ids[i]]; continue; } @@ -1056,6 +1048,7 @@ Zotero.Sync.Server = new function () { } }); Zotero.reloadDataObjects(); + Zotero.Sync.EventListener.resetIgnored(); _syncInProgress = false; return; } @@ -1783,6 +1776,7 @@ Zotero.Sync.Server = new function () { _syncInProgress = false; Zotero.DB.rollbackAllTransactions(); Zotero.reloadDataObjects(); + Zotero.Sync.EventListener.resetIgnored(); if (_sessionID && _sessionLock) { Zotero.Sync.Server.unlock() @@ -2492,12 +2486,10 @@ Zotero.Sync.Server.Data = new function() { if (children.length) { Zotero.Sync.EventListener.ignoreDeletions('item', children); Zotero.Items.erase(children); - Zotero.Sync.EventListener.unignoreDeletions('item', children); } if (parents.length) { Zotero.Sync.EventListener.ignoreDeletions('item', parents); Zotero.Items.erase(parents); - Zotero.Sync.EventListener.unignoreDeletions('item', parents); } // Unlock dateModified for deleted collections @@ -2509,7 +2501,6 @@ Zotero.Sync.Server.Data = new function() { else { Zotero.Sync.EventListener.ignoreDeletions(type, toDelete); Zotero[Types].erase(toDelete); - Zotero.Sync.EventListener.unignoreDeletions(type, toDelete); } }