mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
fix #508
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user