From 4d846e225a40ebea605edf88c2ae973095646f3b Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:02:17 +0200 Subject: [PATCH 1/4] Adds ENV for MaxFailedEpisodeChecks --- server/managers/PodcastManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 052ba8b3..c2fae077 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -30,7 +30,7 @@ class PodcastManager { this.currentDownload = null this.failedCheckMap = {} - this.MaxFailedEpisodeChecks = 24 + this.MaxFailedEpisodeChecks = process.env.MAX_FAILED_EPISODE_CHECKS || 24 } getEpisodeDownloadsInQueue(libraryItemId) { @@ -345,7 +345,7 @@ class PodcastManager { // Allow up to MaxFailedEpisodeChecks failed attempts before disabling auto download if (!this.failedCheckMap[libraryItem.id]) this.failedCheckMap[libraryItem.id] = 0 this.failedCheckMap[libraryItem.id]++ - if (this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) { + if (this.MaxFailedEpisodeChecks != 0 && this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) { Logger.error(`[PodcastManager] runEpisodeCheck ${this.failedCheckMap[libraryItem.id]} failed attempts at checking episodes for "${libraryItem.media.title}" - disabling auto download`) libraryItem.media.autoDownloadEpisodes = false delete this.failedCheckMap[libraryItem.id] From 709c33f27af56a5790bdc5f8312c00b2f8f01eab Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:05:16 +0200 Subject: [PATCH 2/4] ensure proper type --- server/managers/PodcastManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index c2fae077..54ce4c9f 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -30,7 +30,7 @@ class PodcastManager { this.currentDownload = null this.failedCheckMap = {} - this.MaxFailedEpisodeChecks = process.env.MAX_FAILED_EPISODE_CHECKS || 24 + this.MaxFailedEpisodeChecks = parseInt(process.env.MAX_FAILED_EPISODE_CHECKS, 10) || 24 } getEpisodeDownloadsInQueue(libraryItemId) { @@ -345,7 +345,7 @@ class PodcastManager { // Allow up to MaxFailedEpisodeChecks failed attempts before disabling auto download if (!this.failedCheckMap[libraryItem.id]) this.failedCheckMap[libraryItem.id] = 0 this.failedCheckMap[libraryItem.id]++ - if (this.MaxFailedEpisodeChecks != 0 && this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) { + if (this.MaxFailedEpisodeChecks !== 0 && this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) { Logger.error(`[PodcastManager] runEpisodeCheck ${this.failedCheckMap[libraryItem.id]} failed attempts at checking episodes for "${libraryItem.media.title}" - disabling auto download`) libraryItem.media.autoDownloadEpisodes = false delete this.failedCheckMap[libraryItem.id] From 84c9c6cb50d6e4a725d0de6c6cba2449e50eab88 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:07:35 +0200 Subject: [PATCH 3/4] move to global --- server/Server.js | 6 ++++++ server/managers/PodcastManager.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/Server.js b/server/Server.js index 17c959c0..317dab38 100644 --- a/server/Server.js +++ b/server/Server.js @@ -91,6 +91,12 @@ class Server { global.PodcastDownloadTimeout = 30000 } + if (process.env.MAX_FAILED_EPISODE_CHECKS) { + global.MaxFailedEpisodeChecks = process.env.MAX_FAILED_EPISODE_CHECKS + } else { + global.MaxFailedEpisodeChecks = 24 + } + if (!fs.pathExistsSync(global.ConfigPath)) { fs.mkdirSync(global.ConfigPath) } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 54ce4c9f..0c7da925 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -30,7 +30,7 @@ class PodcastManager { this.currentDownload = null this.failedCheckMap = {} - this.MaxFailedEpisodeChecks = parseInt(process.env.MAX_FAILED_EPISODE_CHECKS, 10) || 24 + this.MaxFailedEpisodeChecks = global.MaxFailedEpisodeChecks } getEpisodeDownloadsInQueue(libraryItemId) { From 8e0185907502926b818fc36a2fea844c5dbac588 Mon Sep 17 00:00:00 2001 From: advplyr Date: Thu, 5 Jun 2025 14:31:12 -0500 Subject: [PATCH 4/4] Cast PODCAST_DOWNLOAD_TIMEOUT and MAX_FAILED_EPISODE_CHECKS env vars to numbers --- server/Server.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/server/Server.js b/server/Server.js index 317dab38..5c6f3c16 100644 --- a/server/Server.js +++ b/server/Server.js @@ -12,6 +12,7 @@ const { version } = require('../package.json') // Utils const fileUtils = require('./utils/fileUtils') +const { toNumber } = require('./utils/index') const Logger = require('./Logger') const Auth = require('./Auth') @@ -84,18 +85,8 @@ class Server { global.DisableSsrfRequestFilter = (url) => whitelistedUrls.includes(new URL(url).hostname) } } - - if (process.env.PODCAST_DOWNLOAD_TIMEOUT) { - global.PodcastDownloadTimeout = process.env.PODCAST_DOWNLOAD_TIMEOUT - } else { - global.PodcastDownloadTimeout = 30000 - } - - if (process.env.MAX_FAILED_EPISODE_CHECKS) { - global.MaxFailedEpisodeChecks = process.env.MAX_FAILED_EPISODE_CHECKS - } else { - global.MaxFailedEpisodeChecks = 24 - } + global.PodcastDownloadTimeout = toNumber(process.env.PODCAST_DOWNLOAD_TIMEOUT, 30000) + global.MaxFailedEpisodeChecks = toNumber(process.env.MAX_FAILED_EPISODE_CHECKS, 24) if (!fs.pathExistsSync(global.ConfigPath)) { fs.mkdirSync(global.ConfigPath)