add del event, add download event, add download event video
This commit is contained in:
@@ -285,6 +285,38 @@ router
|
||||
}
|
||||
return n();
|
||||
})
|
||||
.post('/delevent', async(req, res, n) => {
|
||||
if (!config.permission.ipcam) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
let arr = req.body;
|
||||
if (!arr.data) return n('ERR0000');
|
||||
if (!arr.data.dir) return n('ERR0073');
|
||||
|
||||
let rp = config.cmdpath.ipcamsave;
|
||||
let dp = path.resolve(rp, arr.data.dir);
|
||||
try {
|
||||
let stat = await new Promise((resolve, reject) => {
|
||||
fs.stat(dp, (err, stats) => {
|
||||
if (err) return reject(err);
|
||||
return resolve(stats);
|
||||
});
|
||||
});
|
||||
if (dp.split(' ')[0] == '/') return n('ERR0073');
|
||||
await new Promise((resolve, reject) => {
|
||||
exec(`rm -rf ${dp}`, (err, sout, serr) => {
|
||||
if (err) return reject(err);
|
||||
return resolve(null);
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
return rt.err(res, e, n, 'ERR0072');
|
||||
}
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
}
|
||||
return n();
|
||||
})
|
||||
.all('*', rt.send);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user