mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-30 11:29:11 +00:00
Clear upload folder on startup
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
resolveExternalsDirectory,
|
resolveExternalsDirectory,
|
||||||
resolveStylesDirectory,
|
resolveStylesDirectory,
|
||||||
resolvedPath,
|
resolvedPath,
|
||||||
|
clearUploadfolder,
|
||||||
} from './setup/index.js';
|
} from './setup/index.js';
|
||||||
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
||||||
|
|
||||||
@@ -143,6 +144,7 @@ const checkStart = (currentState: OntimeStartOrder) => {
|
|||||||
export const initAssets = async () => {
|
export const initAssets = async () => {
|
||||||
checkStart(OntimeStartOrder.InitAssets);
|
checkStart(OntimeStartOrder.InitAssets);
|
||||||
await dbLoadingProcess;
|
await dbLoadingProcess;
|
||||||
|
await clearUploadfolder();
|
||||||
populateStyles();
|
populateStyles();
|
||||||
populateDemo();
|
populateDemo();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { fileURLToPath } from 'url';
|
|||||||
import path, { dirname, join } from 'path';
|
import path, { dirname, join } from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
|
import { rm } from 'fs/promises';
|
||||||
|
|
||||||
import { config } from './config.js';
|
import { config } from './config.js';
|
||||||
import { ensureDirectory } from '../utils/fileManagement.js';
|
import { ensureDirectory } from '../utils/fileManagement.js';
|
||||||
|
|
||||||
@@ -144,3 +146,11 @@ export const resolveCrashReportDirectory = getAppDataPath();
|
|||||||
|
|
||||||
// path to projects
|
// path to projects
|
||||||
export const resolveProjectsDirectory = join(getAppDataPath(), config.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user