This commit is contained in:
xiaofeng.mxf
2020-01-01 16:18:54 +08:00
parent 2631ca6538
commit ed56e9c159
5 changed files with 54 additions and 47 deletions

View File

@@ -86,11 +86,22 @@ class Recorder extends events.EventEmitter {
this.globalId = 1;
this.cachePath = getCacheDir();
this.db = new Datastore();
this.db.persistence.setAutocompactionInterval(5001);
this.recordBodyMap = []; // id - body
}
setDbAutoCompact() {
this.db.persistence.setAutocompactionInterval(5001);
}
stopDbAutoCompact() {
try {
this.db.persistence.stopAutocompaction();
} catch (e) {
logUtil.printLog(e, logUtil.T_ERR);
}
}
emitUpdate(id, info) {
const self = this;
if (info) {
@@ -333,6 +344,7 @@ class Recorder extends events.EventEmitter {
}
clear() {
logUtil.printLog('clearing cache file...');
const self = this;
proxyUtil.deleteFolderContentsRecursive(self.cachePath, true);
}

View File

@@ -216,8 +216,6 @@ function deleteFolderContentsRecursive(dirPath, ifClearFolderItself) {
throw new Error('can_not_delete_this_dir');
}
logUtil.info('==>>> clearing cache ', dirPath);
if (fs.existsSync(dirPath)) {
fs.readdirSync(dirPath).forEach((file) => {
const curPath = path.join(dirPath, file);

View File

@@ -308,11 +308,15 @@ class webInterface extends events.EventEmitter {
}
close() {
this.server && this.server.close();
this.wsServer && this.wsServer.closeAll();
this.server = null;
this.wsServer = null;
this.proxyInstance = null;
const self = this;
return new Promise((resolve, reject) => {
self.server && self.server.close();
self.wsServer && self.wsServer.closeAll();
self.server = null;
self.wsServer = null;
self.proxyInstance = null;
resolve();
});
}
}