refactor: project service boundaries

This commit is contained in:
Carlos Valente
2024-06-24 14:09:25 +02:00
committed by Carlos Valente
parent 20d9df2501
commit ad69c0ff80
9 changed files with 168 additions and 144 deletions
+13 -1
View File
@@ -1,10 +1,11 @@
import multer from 'multer';
import path from 'path';
import fs from 'fs';
import { rm } from 'fs/promises';
import { rename, rm } from 'fs/promises';
import { ensureDirectory } from './fileManagement.js';
import { getAppDataPath, uploadsFolderPath } from '../setup/index.js';
import { deleteFile } from './parserUtils.js';
function generateNewFileName(filePath: string, callback: (newName: string) => void) {
const baseName = path.basename(filePath, path.extname(filePath));
@@ -68,3 +69,14 @@ export async function clearUploadfolder() {
// we dont care that there was no folder
}
}
/**
* Copies a file from upload folder to a destination
* @param filePath
* @param name
* @returns
*/
export async function moveUploadedFile(fromUpload: string, toDestination: string) {
await rename(fromUpload, toDestination);
await deleteFile(fromUpload);
}