From 17711fcb762b5925c7b32a8165ad6f42d9945041 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sat, 24 Jan 2026 20:08:43 -0400 Subject: [PATCH] Fix #498 : ffmpeg settings can't be updated after ffmpeg path changes. --- src/services/ffmpeg-settings-service.js | 54 +------------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/src/services/ffmpeg-settings-service.js b/src/services/ffmpeg-settings-service.js index 0308488..d6d98df 100644 --- a/src/services/ffmpeg-settings-service.js +++ b/src/services/ffmpeg-settings-service.js @@ -1,7 +1,5 @@ const databaseMigration = require('../database-migration'); const DAY_MS = 1000 * 60 * 60 * 24; -const path = require('path'); -const fs = require('fs'); class FfmpegSettingsService { constructor(db) { @@ -10,9 +8,6 @@ class FfmpegSettingsService { get() { let ffmpeg = this.getCurrentState(); - if (isLocked(ffmpeg)) { - ffmpeg.lock = true; - } // Hid this info from the API delete ffmpeg.ffmpegPathLockDate; return ffmpeg; @@ -21,20 +16,7 @@ class FfmpegSettingsService { update(attempt) { let ffmpeg = this.getCurrentState(); - attempt.ffmpegPathLockDate = ffmpeg.ffmpegPathLockDate; - if (isLocked(ffmpeg)) { - console.log("Note: ffmpeg path is not being updated since it's been locked for your security."); - attempt.ffmpegPath = ffmpeg.ffmpegPath; - if (typeof(ffmpeg.ffmpegPathLockDate) === 'undefined') { - // make sure to lock it even if it was undefined - attempt.ffmpegPathLockDate = new Date().getTime() - DAY_MS; - } - } else if (attempt.addLock === true) { - // lock it right now - attempt.ffmpegPathLockDate = new Date().getTime() - DAY_MS; - } else { - attempt.ffmpegPathLockDate = new Date().getTime() + DAY_MS; - } + delete attempt.ffmpegPathLockDate; delete attempt.addLock; delete attempt.lock; @@ -65,13 +47,7 @@ class FfmpegSettingsService { } function fixupFFMPEGSettings(ffmpeg) { - if (typeof(ffmpeg.ffmpegPath) !== 'string') { - return "ffmpeg path is required." - } - if (! isValidFilePath(ffmpeg.ffmpegPath)) { - return "ffmpeg path must be a valid file path." - } - + if (typeof(ffmpeg.maxFPS) === 'undefined') { ffmpeg.maxFPS = 60; return null; @@ -80,32 +56,6 @@ function fixupFFMPEGSettings(ffmpeg) { } } -//These checks are good but might not be enough, as long as we are letting the -//user choose any path and we are making dizqueTV execute, it is too risky, -//hence why we are also adding the lock feature on top of these checks. -function isValidFilePath(filePath) { - const normalizedPath = path.normalize(filePath); - - if (!path.isAbsolute(normalizedPath)) { - return false; - } - - try { - const stats = fs.statSync(normalizedPath); - return stats.isFile(); - } catch (err) { - // Handle potential errors (e.g., file not found, permission issues) - if (err.code === 'ENOENT') { - return false; // File does not exist - } else { - throw err; // Re-throw other errors for debugging - } - } -} - -function isLocked(ffmpeg) { - return isNaN(ffmpeg.ffmpegPathLockDate) || ffmpeg.ffmpegPathLockDate < new Date().getTime(); -}