diff --git a/app/controllers/webmin.controller.js b/app/controllers/webmin.controller.js index 8bafd2e8a20d6d194412e558b456777d88d2a942..9e2f93ca18cc26ed8de2e1676dbc14bc7a83959b 100644 --- a/app/controllers/webmin.controller.js +++ b/app/controllers/webmin.controller.js @@ -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 {}; }); diff --git a/app/lib/dal/fileDAL.js b/app/lib/dal/fileDAL.js index 9e20945d94404a4beef9df76d26c17a7439f4554..bf8345eb5c76753012fcee5f3fc9ef514097e35d 100644 --- a/app/lib/dal/fileDAL.js +++ b/app/lib/dal/fileDAL.js @@ -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); }); diff --git a/app/lib/dal/sqliteDAL/AbstractSQLite.js b/app/lib/dal/sqliteDAL/AbstractSQLite.js index 095abb0052e13f52670a42acf7727763d026b594..c6ec9d309a61f1e71ed457d9b84c7b9719bc860e 100644 --- a/app/lib/dal/sqliteDAL/AbstractSQLite.js +++ b/app/lib/dal/sqliteDAL/AbstractSQLite.js @@ -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); diff --git a/app/lib/dal/sqliteDAL/BlockDAL.js b/app/lib/dal/sqliteDAL/BlockDAL.js index d5b40b535b9c2aa3f5034fa5e104d9974309204c..84844c8729e675c50206e0afd5215d74e7084bef 100644 --- a/app/lib/dal/sqliteDAL/BlockDAL.js +++ b/app/lib/dal/sqliteDAL/BlockDAL.js @@ -67,8 +67,7 @@ function BlockDAL(db) { 'COMMIT;', []); }); - this.close = () => - current = null; + this.cleanCache = () => current = null; this.getCurrent = () => co(function *() { if (!current) { diff --git a/server.js b/server.js index 8c1fab75ddfb93b3726e2bda4931f0675da4e8e9..cdf2580fd996875a5cdb3b164c695c7502a52191 100644 --- a/server.js +++ b/server.js @@ -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 *() {