From f50cf0ae31c8e4fed1fb7feaea144f2992a208a7 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Thu, 20 Jun 2024 23:17:40 +0100 Subject: [PATCH] fix: maintenance service preview files bug --- backend/services/maintenanceService.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/services/maintenanceService.js b/backend/services/maintenanceService.js index 4723739..19345d4 100644 --- a/backend/services/maintenanceService.js +++ b/backend/services/maintenanceService.js @@ -2,15 +2,15 @@ const path = require('path'); const fsPromises = require('fs').promises; const fs = require('fs'); const Media = require("../models/Media"); -const { getSettings } = require("./settingsService"); const { logToFile } = require('./logService'); +const { getMediaFolder } = require('./mediaService'); async function deleteMissingFilesEntries(dry = false) { const allMedia = await Media.findAll(); // Getting the userDataPath to store the images - const dataPath = getSettings().userDataPath; + const dataPath = await getMediaFolder(); // Handling different media types const mediaTypes = { @@ -20,7 +20,7 @@ async function deleteMissingFilesEntries(dry = false) { }; let missingFiles = []; for (let i = 0; i < allMedia.length; i++) { - let type = `${allMedia[i].type}`; + let type = `${allMedia[i].type}`.replace("_preview", ""); const filePath = path.join(mediaTypes[type], allMedia[i].path) if (!fs.existsSync(filePath)) { missingFiles.push(allMedia[i]); @@ -50,7 +50,7 @@ async function deleteMissingFilesEntries(dry = false) { async function deleteOrphanFiles(dry = false) { // Getting the userDataPath to store the images - const dataPath = getSettings().userDataPath; + const dataPath = getMediaFolder(); // ? Getting the path of all media files and putting them in an array const allMedia = (await Media.findAll()).map(m =>