From fe5419401a3ca08d4eb614a3a720dc0427cdf30c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 21 May 2025 07:28:25 +0000 Subject: [PATCH] chore: use unique filename for health check --- app/controllers/api/health.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 11fc4cc244..825244e776 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -852,15 +852,18 @@ App::get('/v1/health/storage') $checkStart = \microtime(true); foreach ($devices as $device) { - if (!$device->write($device->getPath('health.txt'), 'test', 'text/plain')) { + $uniqueFileName = \uniqid('health', true); + $filePath = $device->getPath($uniqueFileName); + + if (!$device->write($filePath, 'test', 'text/plain')) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed writing test file to ' . $device->getRoot()); } - if ($device->read($device->getPath('health.txt')) !== 'test') { + if ($device->read($filePath) !== 'test') { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed reading test file from ' . $device->getRoot()); } - if (!$device->delete($device->getPath('health.txt'))) { + if (!$device->delete($filePath)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed deleting test file from ' . $device->getRoot()); } }