Skip to content

Commit fe0c3ef

Browse files
villfapxpm
authored andcommitted
Fix CacheMap when cache is corrupted (#169)
# Conflicts: # src/Helpers/CacheMap.php
1 parent f0efeec commit fe0c3ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Helpers/CacheMap.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ public function __construct(FilesystemAdapter $disk, string $basePath)
2626
$this->basePath = $basePath;
2727
$this->filePath = $this->disk->path($this->basePath.'.basset');
2828

29-
// Load map
30-
if (File::exists($this->filePath)) {
31-
$this->map = json_decode(File::get($this->filePath), true);
29+
try {
30+
if (File::exists($this->filePath)) {
31+
$decoded = json_decode(File::get($this->filePath), true);
32+
$this->map = is_array($decoded) ? $decoded : [];
33+
}
34+
} catch (\Throwable) {
35+
$this->map = [];
3236
}
3337
}
3438

0 commit comments

Comments
 (0)