feat: add storage path helpers

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-29 14:12:13 +02:00
co-authored by Claude Sonnet 5
parent a5ab05303f
commit d0faa162dc
2 changed files with 75 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import fs from 'node:fs/promises';
import path from 'node:path';
export async function ensureStorageDirs(config) {
await fs.mkdir(path.join(config.storageDir, 'uploads'), { recursive: true });
await fs.mkdir(path.join(config.storageDir, 'outputs'), { recursive: true });
}
export function uploadPath(config, id, ext) {
return path.join(config.storageDir, 'uploads', `${id}.${ext}`);
}
export function outputPath(config, id, ext) {
return path.join(config.storageDir, 'outputs', `${id}.${ext}`);
}
export async function deleteIfExists(filePath) {
try {
await fs.unlink(filePath);
} catch (error) {
if (error.code !== 'ENOENT') throw error;
}
}