mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-18 04:27:24 +00:00
fix(upgrade): clear stale upgrade flag when version is already current
Refactor upgrade state initialization into a shared `refreshUpgradeState()` method used by both `mount()` and `checkUpdate()`. The method now uses `version_compare` to validate upgrade availability and clears the `new_version_available` flag in InstanceSettings when the current version is already equal to or newer than the latest version, preventing stale upgrade notifications from persisting after a successful update.
This commit is contained in:
@@ -23,25 +23,42 @@ class Upgrade extends Component
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->currentVersion = config('constants.coolify.version');
|
||||
$this->latestVersion = get_latest_version_of_coolify();
|
||||
$this->devMode = isDev();
|
||||
$this->refreshUpgradeState();
|
||||
}
|
||||
|
||||
public function checkUpdate()
|
||||
{
|
||||
try {
|
||||
$this->latestVersion = get_latest_version_of_coolify();
|
||||
$this->currentVersion = config('constants.coolify.version');
|
||||
$this->isUpgradeAvailable = data_get(InstanceSettings::get(), 'new_version_available', false);
|
||||
if (isDev()) {
|
||||
$this->isUpgradeAvailable = true;
|
||||
}
|
||||
$this->refreshUpgradeState();
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
protected function refreshUpgradeState(): void
|
||||
{
|
||||
$this->currentVersion = config('constants.coolify.version');
|
||||
$this->latestVersion = get_latest_version_of_coolify();
|
||||
$this->devMode = isDev();
|
||||
|
||||
if ($this->devMode) {
|
||||
$this->isUpgradeAvailable = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = InstanceSettings::find(0);
|
||||
$hasNewerVersion = version_compare($this->latestVersion, $this->currentVersion, '>');
|
||||
$newVersionAvailable = (bool) data_get($settings, 'new_version_available', false);
|
||||
|
||||
if ($settings && $newVersionAvailable && ! $hasNewerVersion) {
|
||||
$settings->update(['new_version_available' => false]);
|
||||
$newVersionAvailable = false;
|
||||
}
|
||||
|
||||
$this->isUpgradeAvailable = $hasNewerVersion && $newVersionAvailable;
|
||||
}
|
||||
|
||||
public function upgrade()
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user