优化 解压与删除

This commit is contained in:
Suwings 2019-09-17 14:26:10 +08:00
parent 4c08e8426d
commit 4356f7ccfe
3 changed files with 12 additions and 11 deletions

View File

@ -42,7 +42,7 @@ router.post('/rm', (req, res) => {
let fileOperate = new UseFileOperate(req.session.fsos).fileOperate;
let names = filesToPaths(stack, req.session.fsos.cwd);
let obj = fileOperate.batchExectue(fileOperate.rm, names);
sendHandle(req, res, obj);
sendHandle(req, res, true);
});

View File

@ -16,7 +16,7 @@ const realArgv = argv.filter((val, index) => {
if (realArgv.length == 1) {
//解压子进程开始执行
console.log('[解压]', '解压', realArgv, '任务开始');
console.log('[ 解压 ]', '解压', realArgv, '任务开始');
//执行解压
const absPath = realArgv[0];
@ -33,6 +33,6 @@ if (realArgv.length == 1) {
zip.extractAllTo(zipExtractDir, true);
//解压完成,进程终止
console.log('[解压]', '解压', realArgv, '任务结束');
console.log('[ 解压 ]', '解压', realArgv, '任务结束');
process.exit(0);
}

View File

@ -83,17 +83,18 @@ class FileOperate extends BaseFileOperate {
}
_rm_rf(path) { //递归
this._forEachFile(path, (p) => fs.unlinkSync(p));
this._forEachFile(path, (p) => { fs.unlinkSync(p) });
}
rm(path) {
return this.pathAccessCheck(path, (absPath) => {
if (fs.statSync(absPath).isDirectory()) {
this._rm_rf(absPath);
return !fs.existsSync(absPath);
}
fs.unlinkSync(absPath);
return !fs.existsSync(absPath);
this.pathAccessCheck(path, (absPath) => {
// if (fs.statSync(absPath).isDirectory()) {
// this._rm_rf(absPath);
// }
// fs.unlinkSync(absPath);
fsex.remove(absPath, (err) => {
if (err) return;
});
});
}