From 7e9132fcfe37eb120594b3eec759703e30f7e7fd Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Wed, 17 Jul 2024 18:52:40 -0300 Subject: [PATCH] chore: Remove DEL\_TEMP\_INSTANCES variable and related functionality The DEL\_TEMP\_INSTANCES variable and its related functionality have been removed from the .env.example, CHANGELOG.md, and src/api/services/monitor.service.ts files. The `delInstanceFiles` and `deleteTempInstances` methods have been removed from the MonitoringService class. This change simplifies the codebase and removes unnecessary functionality that was not being used. Please note that this change does not impact the current functionalities of the application. However, it's important to update the documentation and any other related files accordingly. Make sure to test the application thoroughly to ensure there are no unintended consequences from this change. --- .env.example | 1 - CHANGELOG.md | 1 + src/api/services/monitor.service.ts | 38 +---------------------------- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/.env.example b/.env.example index 95543c7b..23557cbd 100644 --- a/.env.example +++ b/.env.example @@ -11,7 +11,6 @@ LOG_COLOR=true LOG_BAILEYS=error DEL_INSTANCE=false -DEL_TEMP_INSTANCES=false PROVIDER_ENABLED=false PROVIDER_HOST=127.0.0.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 452301c8..2cfb9843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fixed the function of saving or not saving data in the database * Resolve not find name +* Removed DEL_TEMP_INSTANCES as it is not being used # 2.0.1-beta (2024-07-17 17:01) diff --git a/src/api/services/monitor.service.ts b/src/api/services/monitor.service.ts index 8706feb8..e764f8e2 100644 --- a/src/api/services/monitor.service.ts +++ b/src/api/services/monitor.service.ts @@ -1,6 +1,6 @@ import { execSync } from 'child_process'; import EventEmitter2 from 'eventemitter2'; -import { opendirSync, readdirSync, rmSync } from 'fs'; +import { rmSync } from 'fs'; import { join } from 'path'; import { CacheConf, Chatwoot, ConfigService, Database, DelInstance, ProviderSession } from '../../config/env.config'; @@ -372,40 +372,4 @@ export class WAMonitoringService { } }); } - - private delInstanceFiles() { - setInterval(async () => { - const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' }); - for await (const dirent of dir) { - if (dirent.isDirectory()) { - const files = readdirSync(join(INSTANCE_DIR, dirent.name), { - encoding: 'utf-8', - }); - files.forEach(async (file) => { - if (file.match(/^app.state.*/) || file.match(/^session-.*/)) { - rmSync(join(INSTANCE_DIR, dirent.name, file), { - recursive: true, - force: true, - }); - } - }); - } - } - }, 3600 * 1000 * 2); - } - - private async deleteTempInstances() { - const shouldDelete = this.configService.get('DEL_TEMP_INSTANCES'); - if (!shouldDelete) { - return; - } - const instancesClosed = await this.prismaRepository.instance.findMany({ where: { connectionStatus: 'close' } }); - - let tempInstances = 0; - instancesClosed.forEach((instance) => { - tempInstances++; - this.eventEmitter.emit('remove.instance', instance.id, 'inner'); - }); - this.logger.log('Temp instances removed: ' + tempInstances); - } }