Major Backend Single Responsibility Update part 1

This commit is contained in:
X4Lo committed 2025-01-25 04:29:42 +01:00
1 parent 65177c7553
commit cbdffb21e3
41 files changed
+1723 -888

No files matched your search

+9 -6
View File
@@ -1,16 +1,19 @@
const path = require('path');
const fsPromises = require('fs').promises;
const fs = require('fs');
const Media = require("../models/Media");
const { logToFile } = require('./logService');
const { getMediaFolder } = require('./mediaService');
const Media = require("../models/Media");
const { logToFile } = require('./logService');
const configService = require('./configService');
const _configService = configService;
async function deleteMissingFilesEntries(dry = false) {
const allMedia = await Media.findAll();
// Getting the userDataPath to store the images
const dataPath = await getMediaFolder();
const dataPath = await _configService.getMediaFolder();
// Handling different media types
const mediaTypeFolder = {
@@ -60,7 +63,7 @@ async function deleteMissingFilesEntries(dry = false) {
*/
async function deleteOrphanFiles(dry = false) {
// Getting the userDataPath to store the images
const dataPath = getMediaFolder();
const dataPath = _configService.getMediaFolder();
// ? Getting the path of all media files and putting them in an array
// const allMedia = (await Media.findAll()).map(m => {
@@ -104,7 +107,7 @@ async function deleteOrphanFiles(dry = false) {
// Check each file in the directory
for (let file of files) {
// const filePath = path.join(directory, file);
const filePath = path.join(directory, file);
// // Check if the constructed file path exists in the allMedia array
// // ? this step also takes into account preview files, by removing '_preview'
// // ? and verifying if the file path is in database