From 30a978334828b20bde85af85c8f4b1fd8b4fdc3f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 30 May 2024 19:38:33 +0200 Subject: [PATCH] feat: Add manual update option to UpdateCoolify handle method --- app/Actions/Server/UpdateCoolify.php | 26 ++++++++++++++------------ app/Livewire/Upgrade.php | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 37cb69445..dd126009c 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -14,7 +14,7 @@ class UpdateCoolify public ?string $latestVersion = null; public ?string $currentVersion = null; - public function handle() + public function handle($manual_update = false) { try { $settings = InstanceSettings::get(); @@ -26,17 +26,19 @@ class UpdateCoolify CleanupDocker::run($this->server, false); $this->latestVersion = get_latest_version_of_coolify(); $this->currentVersion = config('version'); - if (!$settings->is_auto_update_enabled) { - Log::debug('Auto update is disabled'); - return; - } - if ($this->latestVersion === $this->currentVersion) { - Log::debug('Already on latest version'); - return; - } - if (version_compare($this->latestVersion, $this->currentVersion, '<')) { - Log::debug('Latest version is lower than current version?!'); - return; + if (!$manual_update) { + if (!$settings->is_auto_update_enabled) { + Log::debug('Auto update is disabled'); + return; + } + if ($this->latestVersion === $this->currentVersion) { + Log::debug('Already on latest version'); + return; + } + if (version_compare($this->latestVersion, $this->currentVersion, '<')) { + Log::debug('Latest version is lower than current version?!'); + return; + } } Log::info("Updating from {$this->currentVersion} -> {$this->latestVersion}"); $this->update(); diff --git a/app/Livewire/Upgrade.php b/app/Livewire/Upgrade.php index ba9fad7fd..5bb4143c0 100644 --- a/app/Livewire/Upgrade.php +++ b/app/Livewire/Upgrade.php @@ -33,7 +33,7 @@ class Upgrade extends Component } $this->rateLimit(1, 60); $this->updateInProgress = true; - UpdateCoolify::run(); + UpdateCoolify::run(manual_update: true); } catch (\Throwable $e) { return handleError($e, $this); }