From 245ddc56e757bdad923fecc1b91811fb8b542878 Mon Sep 17 00:00:00 2001 From: xboard <147830212+cedar2025@users.noreply.github.com> Date: Fri, 26 Sep 2025 19:04:17 +0800 Subject: [PATCH] fix: avoid getCurrentCommit on cache hit --- app/Services/UpdateService.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Services/UpdateService.php b/app/Services/UpdateService.php index 2406d3c..de063cd 100644 --- a/app/Services/UpdateService.php +++ b/app/Services/UpdateService.php @@ -24,8 +24,10 @@ class UpdateService */ public function getCurrentVersion(): string { - $date = Cache::get(self::CACHE_VERSION_DATE, date('Ymd')); - $hash = Cache::get(self::CACHE_VERSION, $this->getCurrentCommit()); + $date = Cache::get(self::CACHE_VERSION_DATE) ?? date('Ymd'); + $hash = Cache::rememberForever(self::CACHE_VERSION, function () { + return $this->getCurrentCommit(); + }); return $date . '-' . $hash; } @@ -49,8 +51,9 @@ class UpdateService // Fallback Cache::forever(self::CACHE_VERSION_DATE, date('Ymd')); - Cache::forever(self::CACHE_VERSION, $this->getCurrentCommit()); - Log::info('Version cache updated (fallback): ' . date('Ymd') . '-' . $this->getCurrentCommit()); + $fallbackHash = $this->getCurrentCommit(); + Cache::forever(self::CACHE_VERSION, $fallbackHash); + Log::info('Version cache updated (fallback): ' . date('Ymd') . '-' . $fallbackHash); } public function checkForUpdates(): array