Clear upload folder on startup

This commit is contained in:
arc-alex
2024-05-27 18:08:48 +02:00
committed by Carlos Valente
parent be852f4546
commit 4beac19c4a
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -2,6 +2,8 @@ import { fileURLToPath } from 'url';
import path, { dirname, join } from 'path';
import fs from 'fs';
import { rm } from 'fs/promises';
import { config } from './config.js';
import { ensureDirectory } from '../utils/fileManagement.js';
@@ -144,3 +146,11 @@ export const resolveCrashReportDirectory = getAppDataPath();
// path to projects
export const resolveProjectsDirectory = join(getAppDataPath(), config.projects);
export async function clearUploadfolder() {
try {
await rm(uploadsFolderPath, { recursive: true });
} catch (_) {
//we dont care that there was no folder
}
}