From 0bcfb47bbcdfa05b706ee2d98ebb9083762215ef Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Wed, 26 Mar 2025 17:57:30 -0400 Subject: [PATCH] fix: patch version override logic incorrect (#1275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary by CodeRabbit - **Bug Fixes** - Improved the system’s version update mechanism so that updates are applied only when the current system version matches the expected version. This enhancement ensures more consistent and reliable version checks during the update process. --- .../plugins/dynamix.my.servers/include/state.php | 13 ++++++++++--- .../dynamix.plugin.manager/include/UnraidCheck.php | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php index 86bd921bf..a418e4316 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php @@ -96,10 +96,17 @@ class ServerState $this->var = $webguiGlobals['var']; - // If we're on a patch, we need to use the combinedVersion to check for updates + $patcherVersion = null; if (file_exists('/tmp/Patcher/patches.json')) { - $patchJson = @json_decode(@file_get_contents('/tmp/Patcher/patches.json'), true) ?: []; - $this->var['version'] = $patchJson['combinedVersion'] ?? $this->var['version']; + $patcherData = @json_decode(file_get_contents('/tmp/Patcher/patches.json'), true); + $unraidVersionInfo = parse_ini_file('/etc/unraid-version'); + if ($patcherData['unraidVersion'] === $unraidVersionInfo['version']) { + $patcherVersion = $patcherData['combinedVersion'] ?? null; + } + } + // If we're on a patch, we need to use the combinedVersion to check for updates + if ($patcherVersion) { + $this->var['version'] = $patcherVersion; } $this->nginxCfg = @parse_ini_file('/var/local/emhttp/nginx.ini') ?? []; diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php index de0b3bb26..a474ea9ba 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php @@ -119,7 +119,10 @@ class UnraidOsCheck $patcherVersion = null; if (file_exists('/tmp/Patcher/patches.json')) { $patcherData = @json_decode(file_get_contents('/tmp/Patcher/patches.json'), true); - $patcherVersion = $patcherData['combinedVersion'] ?? null; + $unraidVersionInfo = parse_ini_file('/etc/unraid-version'); + if ($patcherData['unraidVersion'] === $unraidVersionInfo['version']) { + $patcherVersion = $patcherData['combinedVersion'] ?? null; + } } $params['current_version'] = $patcherVersion ?: plugin('version', self::PLG_PATH) ?: _var($var, 'version');