feat: use patch version if needed on update check (#1227)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced version management so that update checks now prioritize
combined version details obtained from patch data, ensuring more
consistent and reliable version handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Eli Bosley
2025-03-17 14:55:25 -04:00
committed by GitHub
parent 9285eb745e
commit 12e16a6404
2 changed files with 15 additions and 1 deletions

View File

@@ -95,6 +95,13 @@ class ServerState
// echo "<pre>" . json_encode($this->webguiGlobals, JSON_PRETTY_PRINT) . "</pre>";
$this->var = $webguiGlobals['var'];
// If we're on a patch, we need to use the combinedVersion to check for updates
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'];
}
$this->nginxCfg = @parse_ini_file('/var/local/emhttp/nginx.ini') ?? [];
$this->state = strtoupper(empty($this->var['regCheck']) ? $this->var['regTy'] : $this->var['regCheck']);

View File

@@ -115,7 +115,14 @@ class UnraidOsCheck
$params = [];
$params['branch'] = plugin('category', self::PLG_PATH, 'stable');
$params['current_version'] = plugin('version', self::PLG_PATH) ?: _var($var,'version');
// Get current version from patches.json if it exists, otherwise fall back to plugin version or var.ini
$patcherVersion = null;
if (file_exists('/tmp/Patcher/patches.json')) {
$patcherData = @json_decode(file_get_contents('/tmp/Patcher/patches.json'), true);
$patcherVersion = $patcherData['combinedVersion'] ?? null;
}
$params['current_version'] = $patcherVersion ?: plugin('version', self::PLG_PATH) ?: _var($var, 'version');
if (_var($var,'regExp')) $params['update_exp'] = date('Y-m-d', _var($var,'regExp')*1);
$defaultUrl = self::BASE_RELEASES_URL;
// pass a param of altUrl to use the provided url instead of the default