mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
refactor: minor code cleanups
This commit is contained in:
committed by
Carlos Valente
parent
0335da9786
commit
20503de6fd
@@ -10,7 +10,7 @@ export function consoleSuccess(message: string) {
|
||||
/**
|
||||
* Utility function to log messages in red
|
||||
*/
|
||||
export function consoleRed(message: string) {
|
||||
export function consoleError(message: string) {
|
||||
console.error(inRed(message));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { get } from '../services/rundown-service/rundownCache.js';
|
||||
import { getState } from '../stores/runtimeState.js';
|
||||
import { resolveCrashReportDirectory } from '../setup/index.js';
|
||||
|
||||
import { ensureDirectory } from './fileManagement.js';
|
||||
/**
|
||||
* Writes a file to the crash report location
|
||||
* @param fileName
|
||||
@@ -13,10 +14,12 @@ import { resolveCrashReportDirectory } from '../setup/index.js';
|
||||
*/
|
||||
function writeToFile(fileName: string, content: object) {
|
||||
const path = join(resolveCrashReportDirectory, fileName);
|
||||
ensureDirectory(resolveCrashReportDirectory);
|
||||
|
||||
try {
|
||||
const textContent = JSON.stringify(content, null, 2);
|
||||
writeFileSync(path, textContent);
|
||||
} catch (e_rror) {
|
||||
} catch (_) {
|
||||
/** We do not handle the error here */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import multer from 'multer';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { rm } from 'fs/promises';
|
||||
|
||||
import { ensureDirectory } from './fileManagement.js';
|
||||
import { getAppDataPath, uploadsFolderPath } from '../setup/index.js';
|
||||
@@ -56,3 +57,11 @@ export const storage = multer.diskStorage({
|
||||
cb(null, file.originalname);
|
||||
},
|
||||
});
|
||||
|
||||
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