|
@@ -102,27 +102,27 @@ function getLastFile(dirPath, number, callback) {
|
|
|
let fileList = [];
|
|
|
//提示日志默认是根据日志生成的,拿到的files 也是 按照生成日志排序的,所以
|
|
|
// 按照倒叙获取,如果一个文件内容满足num,就不在继续查询,如果不够,继续获取文件
|
|
|
- for (var i = files.length - 1; i >= 0; i--) {
|
|
|
- var file = files[i];
|
|
|
- logger.info(`--------02..00`, dirPath, file,i,files.length)
|
|
|
- const filePath = path.join(dirPath, file);
|
|
|
- const stats = await fs.promises.stat(filePath);
|
|
|
- fileList.push({name: file, time: stats.mtimeMs});
|
|
|
-
|
|
|
- if (fileList.length > number) {//如果够 number 就不再继续获取文件
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // for (file of files) {
|
|
|
- //
|
|
|
+ // for (var i = files.length - 1; i >= 0; i--) {
|
|
|
+ // var file = files[i];
|
|
|
+ // logger.info(`--------02..00`, dirPath, file,i,files.length,fileList.length)
|
|
|
// const filePath = path.join(dirPath, file);
|
|
|
- // logger.info(`--------02..111`, filePath)
|
|
|
// const stats = await fs.promises.stat(filePath);
|
|
|
- // logger.info(`--------02..22222`, stats)
|
|
|
// fileList.push({name: file, time: stats.mtimeMs});
|
|
|
+ //
|
|
|
+ // if (fileList.length > number) {//如果够 number 就不再继续获取文件
|
|
|
+ // break
|
|
|
+ // }
|
|
|
// }
|
|
|
|
|
|
+ for (file of files) {
|
|
|
+ logger.info(`--------02..00`, dirPath, file,files.length,fileList.length)
|
|
|
+ const filePath = path.join(dirPath, file);
|
|
|
+ logger.info(`--------02..111`, filePath)
|
|
|
+ const stats = await fs.promises.stat(filePath);
|
|
|
+ logger.info(`--------02..22222`, stats)
|
|
|
+ fileList.push({name: file, time: stats.mtimeMs});
|
|
|
+ }
|
|
|
+
|
|
|
logger.info(`--------03`)
|
|
|
fileList.sort((a, b) => b.time - a.time);
|
|
|
logger.info(`--------04`)
|