corrected log

This commit is contained in:
microprocessgit 2024-01-04 07:05:56 -03:00
parent adc7d29341
commit 1a2546c52b
4 changed files with 24 additions and 5 deletions

18
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"protocol": "inspector",
"restart": true,
"name": "Debug",
"skipFiles": [
"<node_internals>/**"
]
}
]
}

View File

View File

@ -7,7 +7,7 @@
"build": "tsc",
"start": "ts-node --files --transpile-only ./src/main.ts",
"start:prod": "bash start.sh",
"dev:server": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",
"dev": "ts-node-dev --inspect --transpile-only --ignore-watch node_modules ./src/main.ts",
"test": "clear && tsnd --files --transpile-only --respawn --ignore-watch node_modules ./test/all.test.ts",
"lint": "eslint --fix --ext .ts src"
},
@ -46,7 +46,7 @@
"@figuro/chatwoot-sdk": "^1.1.16",
"@hapi/boom": "^10.0.1",
"@sentry/node": "^7.59.2",
"@whiskeysockets/baileys": "github:PurpShell/Baileys#combined",
"@whiskeysockets/baileys": "^6.5.0",
"amqplib": "^0.10.3",
"aws-sdk": "^2.1499.0",
"axios": "^1.3.5",

View File

@ -174,10 +174,11 @@ function salvarLog(env: any, log: string): void {
function excluirArquivosAntigos(path: string, diasLimite: number): void {
const data = new Date();
data.setDate(data.getDate() - diasLimite);
let limite = Number.parseInt(data.toLocaleDateString().replaceAll('/', ''));
fs.readdirSync(path).forEach((nomeArquivo) => {
let file = Number.parseInt(nomeArquivo.replace(/^.*[\\\/]/, '').replace(/\.[^/.]+$/, ''));
if (file < limite) {
let Timerfile = new Date(parseInt(nomeArquivo.substring(8, 4)),
parseInt(nomeArquivo.substring(4, 2)), parseInt(nomeArquivo.substring(2, 0)))
if (Timerfile.getTime() < data.getTime()) {
fs.unlinkSync(path + '/' + nomeArquivo);
console.log(`Arquivo ${nomeArquivo} excluído.`);
}