From aa73d8dcc7cd6c831f475afc12fcb13065622635 Mon Sep 17 00:00:00 2001 From: Ricardo Sawir <37329575+sawirricardo@users.noreply.github.com> Date: Fri, 11 Aug 2023 15:00:38 +0700 Subject: [PATCH 1/3] Make Sushi Cache Path more customizeable This is useful if we want to change how the cache path generation is handled --- src/Sushi.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Sushi.php b/src/Sushi.php index 2320e50..c868acd 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -36,13 +36,29 @@ public static function resolveConnection($connection = null) return static::$sushiConnection; } + protected function sushiCachePath() + { + return implode(DIRECTORY_SEPARATOR, [ + $this->sushiCacheDirectory(), + $this->sushiCacheFileName(), + ]); + } + + protected function sushiCacheFileName() + { + return config('sushi.cache-prefix', 'sushi').'-'.Str::kebab(str_replace('\\', '', static::class)).'.sqlite'; + } + + protected function sushiCacheDirectory() + { + return realpath(config('sushi.cache-path', storage_path('framework/cache'))); + } + public static function bootSushi() { $instance = (new static); - $cacheFileName = config('sushi.cache-prefix', 'sushi').'-'.Str::kebab(str_replace('\\', '', static::class)).'.sqlite'; - $cacheDirectory = realpath(config('sushi.cache-path', storage_path('framework/cache'))); - $cachePath = $cacheDirectory.'/'.$cacheFileName; + $cachePath = $instance->sushiCachePath(); $dataPath = $instance->sushiCacheReferencePath(); $states = [ From 488c4bec78595ebcf7104a86e0f123b818625216 Mon Sep 17 00:00:00 2001 From: Ricardo Sawir <37329575+sawirricardo@users.noreply.github.com> Date: Fri, 11 Aug 2023 15:12:05 +0700 Subject: [PATCH 2/3] bugfix failed tests --- src/Sushi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sushi.php b/src/Sushi.php index c868acd..1e899ce 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -90,7 +90,7 @@ public static function bootSushi() $states['cache-file-found-and-up-to-date'](); break; - case file_exists($cacheDirectory) && is_writable($cacheDirectory): + case file_exists($instance->cacheDirectory()) && is_writable($instance->cacheDirectory()): $states['cache-file-not-found-or-stale'](); break; From 747f5c8ffad74decdcbee48161ccb7719e2bd6b1 Mon Sep 17 00:00:00 2001 From: sawirricardo Date: Mon, 14 Aug 2023 09:57:00 +0700 Subject: [PATCH 3/3] bugfix --- src/Sushi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sushi.php b/src/Sushi.php index 1e899ce..f739779 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -90,7 +90,7 @@ public static function bootSushi() $states['cache-file-found-and-up-to-date'](); break; - case file_exists($instance->cacheDirectory()) && is_writable($instance->cacheDirectory()): + case file_exists($instance->sushiCacheDirectory()) && is_writable($instance->sushiCacheDirectory()): $states['cache-file-not-found-or-stale'](); break;