Commit db7ea813 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Data reset was not working on Windows

parent 5342acca
......@@ -374,10 +374,7 @@ function WebAdmin (dbConf, overConf) {
yield pluggedDALP;
// We have to wait for a non-breaking window to process reset
yield server.BlockchainService.pushFIFO(() => co(function *() {
yield server.unPlugFileSystem();
yield server.resetData();
pluggedConfP = plugForConf();
pluggedDALP = plugForDAL();
yield server.softResetData();
}));
return {};
});
......
......@@ -1114,9 +1114,21 @@ function FileDAL(params) {
this.loadStats = that.statDAL.loadStats;
this.getStat = that.statDAL.getStat;
this.pushStats = that.statDAL.pushStats;
this.cleanCaches = () => co(function *() {
yield _.values(that.newDals).map((dal) => dal.cleanCache && dal.cleanCache());
});
this.cleanDBData = () => co(function *() {
yield _.values(that.newDals).map((dal) => dal.cleanData && dal.cleanData());
that.wotb.resetWoT();
var files = ['stats', 'cores', 'current'];
var dirs = ['blocks', 'ud_history', 'branches', 'certs', 'txs', 'cores', 'sources', 'links', 'ms', 'identities', 'peers', 'indicators', 'leveldb'];
return resetFiles(files, dirs);
});
this.close = () => co(function *() {
yield _.values(that.newDals).map((dal) => dal.close && dal.close());
yield _.values(that.newDals).map((dal) => dal.cleanCache && dal.cleanCache());
return Q.nbind(sqlite.close, sqlite);
});
......
......@@ -49,6 +49,8 @@ function AbstractSQLite(db) {
}
});
this.cleanData = () => this.query("DELETE FROM " + this.table);
this.sqlListAll = () => this.query("SELECT * FROM " + this.table);
this.sqlDeleteAll = () => this.exec("DELETE FROM " + this.table);
......
......@@ -67,8 +67,7 @@ function BlockDAL(db) {
'COMMIT;', []);
});
this.close = () =>
current = null;
this.cleanCache = () => current = null;
this.getCurrent = () => co(function *() {
if (!current) {
......
......@@ -57,9 +57,11 @@ function Server (dbConf, overrideConf) {
that.dal = fileDAL(params);
});
this.unPlugFileSystem = () => co(function *() {
logger.debug('Unplugging file system...');
yield that.dal.close();
this.softResetData = () => co(function *() {
logger.debug('Soft data reset... [cache]');
yield that.dal.cleanCaches();
logger.debug('Soft data reset... [data]');
yield that.dal.cleanDBData();
});
this.loadConf = (useDefaultConf) => co(function *() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment