Add support function to reset the DB and a test that it works.

This commit is contained in:
Simon Kornblith 2015-03-09 14:25:49 -04:00
parent b6673511f7
commit c7c58f8343
5 changed files with 41 additions and 2 deletions

View file

@ -177,6 +177,21 @@ ZoteroContext.prototype = {
}
return zContext;
},
/**
* Shuts down Zotero, calls a callback (that may return a promise),
* then reinitializes Zotero. Returns a promise that is resolved
* when this process completes.
*/
"reinit":function(cb, isConnector) {
Services.obs.notifyObservers(zContext.Zotero, "zotero-before-reload", isConnector ? "connector" : "full");
return zContext.Zotero.shutdown().then(function() {
return cb ? cb() : false;
}).finally(function() {
makeZoteroContext(isConnector);
zContext.Zotero.init(zInitOptions);
});
}
};