mirror of
https://github.com/unraid/api.git
synced 2026-01-06 16:49:49 -06:00
refactor: restructure ServerState class for update checks
- Moved the initialization of `UnraidOsCheck` to a new method `initializeOsCheck()` for better organization. - Ensured that the update check runs before any other operations to guarantee the latest `var.ini` values are used. This change enhances the clarity and maintainability of the `ServerState` class.
This commit is contained in:
@@ -105,15 +105,11 @@ class ServerState
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->updateOsCheck = new UnraidOsCheck();
|
||||
/**
|
||||
* This is positioned here to ensure that if during the UpdateOSCheck, which includes a ReplaceKeyCheck,
|
||||
* that we get the latest var.ini values before anything else attempts to use them throughout the class.
|
||||
* Run update check before any other operations to ensure
|
||||
* var.ini has latest values after potential key replacements
|
||||
*/
|
||||
$updateCheck = $this->shouldCheckForUpdates();
|
||||
if ($updateCheck) {
|
||||
$this->updateOsCheck->checkForUpdate($updateCheck['forceReplaceKeyCheck']);
|
||||
}
|
||||
$this->initializeOsCheck();
|
||||
/**
|
||||
* @note – necessary evil until full webgui is class based.
|
||||
* @see - getWebguiGlobal() for usage
|
||||
@@ -154,6 +150,16 @@ class ServerState
|
||||
$this->detectActivationCode();
|
||||
}
|
||||
|
||||
private function initializeOsCheck(): void
|
||||
{
|
||||
$this->updateOsCheck = new UnraidOsCheck();
|
||||
|
||||
$updateCheck = $this->shouldCheckForUpdates();
|
||||
if ($updateCheck) {
|
||||
$this->updateOsCheck->checkForUpdate($updateCheck['forceReplaceKeyCheck']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value of a webgui global setting.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user