change routes

This commit is contained in:
joseph le 2023-08-22 11:07:49 +07:00
parent 065425b0d4
commit 78cb8b61cb
1 changed files with 7 additions and 8 deletions

View File

@ -18,14 +18,13 @@ export function runtimeCheckLogs(folderPath) {
fileList.map((file) => {
const filePath = `${folderPath}/${file}`;
const stats = fs.statSync(filePath);
if (file.search("log.") === -1) {
const stats = fs.statSync(filePath);
//scan file today
if (
dateNow !== moment(stats.mtime).format("YYYY/MM/DD") ||
file.search("log.") !== -1
) {
fileList = fileList.filter((i) => i !== file);
//scan file today
if (dateNow !== moment(stats.mtime).format("YYYY/MM/DD")) {
fileList = fileList.filter((i) => i !== file);
}
}
});
}
@ -35,9 +34,9 @@ export function runtimeCheckLogs(folderPath) {
// folderWatcher.setMaxListeners(20);
folderWatcher.on("add", async (filePath) => {
console.log(`New file added: ${filePath}`);
//import log new file
if (filePath.search("log.") !== -1) {
console.log(`New file added: ${filePath}`);
await LogDetectFile.firstOrCreate(
{ file_name: filePath.split("/")[filePath.split("/").length - 1] },
{ file_name: filePath.split("/")[filePath.split("/").length - 1] }