From d81efd7a752586d474f35a57c0a0d30d91a0626d Mon Sep 17 00:00:00 2001 From: Angger Pradana Date: Sat, 21 Sep 2024 06:26:42 +0700 Subject: [PATCH] fix: prevent cache `FileStorage::class` delete gitignore (#391) --- src/System/Cache/Storage/FileStorage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/System/Cache/Storage/FileStorage.php b/src/System/Cache/Storage/FileStorage.php index 4481e836..0ece9bb8 100644 --- a/src/System/Cache/Storage/FileStorage.php +++ b/src/System/Cache/Storage/FileStorage.php @@ -103,8 +103,14 @@ public function clear(): bool ); foreach ($files as $fileinfo) { + $filePath = $fileinfo->getRealPath(); + + if (basename($filePath) === '.gitignore') { + continue; + } + $action = $fileinfo->isDir() ? 'rmdir' : 'unlink'; - $action($fileinfo->getRealPath()); + $action($filePath); } return true;