mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
fix: Resolve 'no such file or directory' error (#123)
This commit fixes an issue where a 'no such file or directory' error was being thrown. The error was caused by the absence of a temporary directory used for storing data. To resolve this issue, the `initStoreFolders` method was added to the `PrismaRepository` class, which creates the necessary store path and temporary directory during initialization. The modifications include changes to the `repository.service.ts` file, where the `initStoreFolders` method was implemented. The `fs` and `path` modules were imported to facilitate file system operations. With these changes, the error should no longer occur, ensuring the proper functioning of the application.
This commit is contained in:
parent
49ad9812a4
commit
634ee9b4b3
@ -1,4 +1,6 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import fs from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
@ -13,10 +15,29 @@ export class Query<T> {
|
||||
export class PrismaRepository extends PrismaClient {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
super();
|
||||
|
||||
this.initStoreFolders();
|
||||
}
|
||||
|
||||
private readonly logger = new Logger(PrismaRepository.name);
|
||||
|
||||
private async initStoreFolders() {
|
||||
try {
|
||||
const storePath = join(process.cwd(), 'store');
|
||||
|
||||
this.logger.verbose('creating store path: ' + storePath);
|
||||
|
||||
const tempDir = join(storePath, 'temp');
|
||||
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
this.logger.verbose('creating temp dir: ' + tempDir);
|
||||
fs.mkdirSync(tempDir, { recursive: true });
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async onModuleInit() {
|
||||
await this.$connect();
|
||||
this.logger.info('Repository:Prisma - ON');
|
||||
|
Loading…
Reference in New Issue
Block a user