commit e3acd9a5138bd2a6ead45bf981c8b4c93d4f0a4c
parent 088c057837035b23c39133548537d085a066f450
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 3 Sep 2008 18:04:50 +0000
Better cleanup of cached data after sync error
Clearer error message for "Creator must be a Zotero.Creator object in Zotero.Item.setCreator()" problem (which isn't yet fixed)
Diffstat:
4 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/creators.js b/chrome/content/zotero/xpcom/data/creators.js
@@ -36,7 +36,6 @@ Zotero.Creators = new function() {
this.updateData = updateData;
this.deleteData = deleteData;
this.reload = reload;
- this.reloadAll = reloadAll;
this.erase = erase;
this.purge = purge;
this.unload = unload;
@@ -200,20 +199,6 @@ Zotero.Creators = new function() {
}
- function reloadAll() {
- Zotero.debug("Reloading all creators");
- _creatorDataHash = {};
- for (var id in _creatorsByID) {
- _creatorsByID[id].load();
- var realID = _creatorsByID[id].id;
- if (realID != id) {
- Zotero.debug("Clearing cache entry for creator " + id);
- delete _creatorsByID[id];
- }
- }
- }
-
-
/**
* Remove creator(s) from all linked items and call this.purge()
* to delete creator rows
@@ -300,6 +285,13 @@ Zotero.Creators = new function() {
}
+ this.unloadAll = function () {
+ Zotero.debug("Unloading all creators");
+ _creatorsByID = {};
+ _creatorDataHash = {};
+ }
+
+
function _cleanFields(fields) {
var cleanedFields = {
firstName: '',
diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js
@@ -28,8 +28,8 @@ Zotero.Tags = new function() {
Zotero.DataObjects.apply(this, ['tag']);
this.constructor.prototype = new Zotero.DataObjects();
- var _tags = []; // indexed by tag text
- var _tagsByID = []; // indexed by tagID
+ var _tags = {}; // indexed by tag text
+ var _tagsByID = {}; // indexed by tagID
this.get = get;
this.getName = getName;
@@ -426,5 +426,11 @@ Zotero.Tags = new function() {
}
}
}
+
+
+ this.unloadAll = function (ids) {
+ _tags = {};
+ _tagsByID = {};
+ }
}
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1234,6 +1234,7 @@ Zotero.Sync.Server = new function () {
_syncInProgress = false;
_resetAttempts();
Zotero.DB.rollbackAllTransactions();
+ Zotero.reloadDataObjects();
if (_sessionID && _sessionLock) {
Zotero.Sync.Server.unlock()
@@ -1497,8 +1498,9 @@ Zotero.Sync.Server.Data = new function() {
}
if (type != 'item') {
- alert('Reconciliation unimplemented for ' + types);
- throw ('Reconciliation unimplemented for ' + types);
+ var msg = "Reconciliation unimplemented for " + types;
+ alert(msg);
+ throw(msg);
}
if (obj.isAttachment()) {
@@ -2123,9 +2125,14 @@ Zotero.Sync.Server.Data = new function() {
throw ('No creator in position ' + i);
}
+ var creatorID = parseInt(creator.@id);
+ var creatorObj = Zotero.Creators.get(creatorID);
+ if (!creatorObj) {
+ throw ("Creator " + creatorID + " does not exist");
+ }
item.setCreator(
pos,
- Zotero.Creators.get(parseInt(creator.@id)),
+ creatorObj,
creator.@creatorType.toString()
);
i++;
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -913,8 +913,9 @@ var Zotero = new function(){
function reloadDataObjects() {
+ Zotero.Tags.unloadAll();
Zotero.Collections.reloadAll();
- Zotero.Creators.reloadAll();
+ Zotero.Creators.unloadAll();
Zotero.Items.reloadAll();
}
};