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)
This commit is contained in:
parent
088c057837
commit
e3acd9a513
|
@ -36,7 +36,6 @@ Zotero.Creators = new function() {
|
||||||
this.updateData = updateData;
|
this.updateData = updateData;
|
||||||
this.deleteData = deleteData;
|
this.deleteData = deleteData;
|
||||||
this.reload = reload;
|
this.reload = reload;
|
||||||
this.reloadAll = reloadAll;
|
|
||||||
this.erase = erase;
|
this.erase = erase;
|
||||||
this.purge = purge;
|
this.purge = purge;
|
||||||
this.unload = unload;
|
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()
|
* Remove creator(s) from all linked items and call this.purge()
|
||||||
* to delete creator rows
|
* 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) {
|
function _cleanFields(fields) {
|
||||||
var cleanedFields = {
|
var cleanedFields = {
|
||||||
firstName: '',
|
firstName: '',
|
||||||
|
|
|
@ -28,8 +28,8 @@ Zotero.Tags = new function() {
|
||||||
Zotero.DataObjects.apply(this, ['tag']);
|
Zotero.DataObjects.apply(this, ['tag']);
|
||||||
this.constructor.prototype = new Zotero.DataObjects();
|
this.constructor.prototype = new Zotero.DataObjects();
|
||||||
|
|
||||||
var _tags = []; // indexed by tag text
|
var _tags = {}; // indexed by tag text
|
||||||
var _tagsByID = []; // indexed by tagID
|
var _tagsByID = {}; // indexed by tagID
|
||||||
|
|
||||||
this.get = get;
|
this.get = get;
|
||||||
this.getName = getName;
|
this.getName = getName;
|
||||||
|
@ -426,5 +426,11 @@ Zotero.Tags = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.unloadAll = function (ids) {
|
||||||
|
_tags = {};
|
||||||
|
_tagsByID = {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1234,6 +1234,7 @@ Zotero.Sync.Server = new function () {
|
||||||
_syncInProgress = false;
|
_syncInProgress = false;
|
||||||
_resetAttempts();
|
_resetAttempts();
|
||||||
Zotero.DB.rollbackAllTransactions();
|
Zotero.DB.rollbackAllTransactions();
|
||||||
|
Zotero.reloadDataObjects();
|
||||||
|
|
||||||
if (_sessionID && _sessionLock) {
|
if (_sessionID && _sessionLock) {
|
||||||
Zotero.Sync.Server.unlock()
|
Zotero.Sync.Server.unlock()
|
||||||
|
@ -1497,8 +1498,9 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != 'item') {
|
if (type != 'item') {
|
||||||
alert('Reconciliation unimplemented for ' + types);
|
var msg = "Reconciliation unimplemented for " + types;
|
||||||
throw ('Reconciliation unimplemented for ' + types);
|
alert(msg);
|
||||||
|
throw(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.isAttachment()) {
|
if (obj.isAttachment()) {
|
||||||
|
@ -2123,9 +2125,14 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
throw ('No creator in position ' + i);
|
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(
|
item.setCreator(
|
||||||
pos,
|
pos,
|
||||||
Zotero.Creators.get(parseInt(creator.@id)),
|
creatorObj,
|
||||||
creator.@creatorType.toString()
|
creator.@creatorType.toString()
|
||||||
);
|
);
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -913,8 +913,9 @@ var Zotero = new function(){
|
||||||
|
|
||||||
|
|
||||||
function reloadDataObjects() {
|
function reloadDataObjects() {
|
||||||
|
Zotero.Tags.unloadAll();
|
||||||
Zotero.Collections.reloadAll();
|
Zotero.Collections.reloadAll();
|
||||||
Zotero.Creators.reloadAll();
|
Zotero.Creators.unloadAll();
|
||||||
Zotero.Items.reloadAll();
|
Zotero.Items.reloadAll();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user