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); - } }