Don't unload object on save error if not new

This commit is contained in:
Dan Stillman 2017-02-02 22:34:12 -05:00
parent 79a07cad9e
commit 76bc61e882

View file

@ -909,14 +909,16 @@ Zotero.DataObject.prototype._initSave = Zotero.Promise.coroutine(function* (env)
}
// Undo registerObject() on failure
var func = function () {
this.ObjectsClass.unload(this._id);
}.bind(this);
if (env.options.tx) {
env.transactionOptions.onRollback = func;
}
else {
Zotero.DB.addCurrentCallback("rollback", func);
if (env.isNew) {
var func = function () {
this.ObjectsClass.unload(this._id);
}.bind(this);
if (env.options.tx) {
env.transactionOptions.onRollback = func;
}
else {
Zotero.DB.addCurrentCallback("rollback", func);
}
}
env.relationsToRegister = [];