ui 고치기 전 세이브
This commit is contained in:
@@ -50,11 +50,25 @@ class MailTemplateFileService {
|
||||
process.env.NODE_ENV === "production"
|
||||
? "/app/uploads/mail-templates"
|
||||
: path.join(process.cwd(), "uploads", "mail-templates");
|
||||
this.ensureDirectoryExists();
|
||||
// 동기적으로 디렉토리 생성
|
||||
this.ensureDirectoryExistsSync();
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 디렉토리 생성
|
||||
* 템플릿 디렉토리 생성 (동기)
|
||||
*/
|
||||
private ensureDirectoryExistsSync() {
|
||||
try {
|
||||
const fsSync = require('fs');
|
||||
fsSync.accessSync(this.templatesDir);
|
||||
} catch {
|
||||
const fsSync = require('fs');
|
||||
fsSync.mkdirSync(this.templatesDir, { recursive: true, mode: 0o755 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 디렉토리 생성 (비동기)
|
||||
*/
|
||||
private async ensureDirectoryExists() {
|
||||
try {
|
||||
@@ -75,8 +89,6 @@ class MailTemplateFileService {
|
||||
* 모든 템플릿 목록 조회
|
||||
*/
|
||||
async getAllTemplates(): Promise<MailTemplate[]> {
|
||||
await this.ensureDirectoryExists();
|
||||
|
||||
try {
|
||||
const files = await fs.readdir(this.templatesDir);
|
||||
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
||||
@@ -97,6 +109,7 @@ class MailTemplateFileService {
|
||||
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
|
||||
);
|
||||
} catch (error) {
|
||||
// 디렉토리가 없거나 읽기 실패 시 빈 배열 반환
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user