|
@@ -158,10 +158,8 @@ function init() {
|
|
|
if (port === -1){
|
|
|
return res.status(404).send('机器人不存在!');
|
|
|
}
|
|
|
- const logPath = "./db" + port;
|
|
|
- const directoryPath = path.resolve(logPath);
|
|
|
- // logger.info('文件目录:' + directoryPath)
|
|
|
- const latestFile = getLatestFile(directoryPath);
|
|
|
+ const logPath = "./db/" + port + ".html";
|
|
|
+ const latestFile = path.resolve(logPath);
|
|
|
|
|
|
if (!latestFile) {
|
|
|
return res.status(404).send('没有找到文件。');
|
|
@@ -233,24 +231,6 @@ function isOK(req, res) {
|
|
|
res.send({'code': 200, 'data': "null", "message": "SUCCESS"});
|
|
|
}
|
|
|
|
|
|
-function getLatestFile(dir) {
|
|
|
- const files = fs.readdirSync(dir);
|
|
|
- let latestFile = null;
|
|
|
- let latestStat = null;
|
|
|
-
|
|
|
- files.forEach(file => {
|
|
|
- const filePath = path.join(dir, file);
|
|
|
- const stat = fs.statSync(filePath);
|
|
|
-
|
|
|
- if (!latestStat || stat.birthtime > latestStat.birthtime) {
|
|
|
- latestStat = stat;
|
|
|
- latestFile = filePath;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- return latestFile;
|
|
|
-}
|
|
|
-
|
|
|
// 日志读取操作
|
|
|
module.exports = {
|
|
|
init,
|