An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(storage): clear stale disk usage cache
Andras Bacsai097efd14ce2d
diff --git a/app/Jobs/PushServerUpdateJob.php b/app/Jobs/PushServerUpdateJob.phpindex cdfa174ed0..e75509f62d 100644--- a/app/Jobs/PushServerUpdateJob.php+++ b/app/Jobs/PushServerUpdateJob.php@@ -143,6 +143,8 @@ class PushServerUpdateJob implements ShouldBeEncrypted, ShouldQueue, Silenced&& (string) $lastPercentage !== (string) $filesystemUsageRoot) {Cache::put($storageCacheKey, $filesystemUsageRoot, 600);ServerStorageCheckJob::dispatch($this->server, $filesystemUsageRoot);+ } elseif ($filesystemUsageRoot !== null && $filesystemUsageRoot < $diskThreshold) {+ Cache::forget($storageCacheKey);}if ($this->containers->isEmpty()) {diff --git a/tests/Feature/PushServerUpdateJobOptimizationTest.php b/tests/Feature/PushServerUpdateJobOptimizationTest.phpindex 92c98a2e19..c7537bb498 100644--- a/tests/Feature/PushServerUpdateJobOptimizationTest.php+++ b/tests/Feature/PushServerUpdateJobOptimizationTest.php@@ -50,6 +50,39 @@ it('does not dispatch storage check when disk usage is below threshold', functioQueue::assertNotPushed(ServerStorageCheckJob::class);});+it('clears stale storage cache when disk usage drops below threshold', function () {+ $team = Team::factory()->create();+ $server = Server::factory()->create(['team_id' => $team->id]);+ $storageCacheKey = 'storage-check:'.$server->id;++ Cache::put($storageCacheKey, 85, 600);++ $belowThresholdData = [+ 'containers' => [],+ 'filesystem_usage_root' => ['used_percentage' => 45],+ ];++ $job = new PushServerUpdateJob($server, $belowThresholdData);+ $job->handle();++ Queue::assertNotPushed(ServerStorageCheckJob::class);+ expect(Cache::missing($storageCacheKey))->toBeTrue();++ Queue::fake();++ $aboveThresholdData = [+ 'containers' => [],+ 'filesystem_usage_root' => ['used_percentage' => 85],+ ];++ $job = new PushServerUpdateJob($server, $aboveThresholdData);+ $job->handle();++ Queue::assertPushed(ServerStorageCheckJob::class, function ($job) use ($server) {+ return $job->server->id === $server->id && $job->percentage === 85;+ });+});+it('does not dispatch storage check when disk percentage is unchanged', function () {$team = Team::factory()->create();$server = Server::factory()->create(['team_id' => $team->id]);