Skip to content

Commit

Permalink
fix: Remove cache file & regenerate it if is corrupt.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 14, 2024
1 parent a99ccec commit b6b1cf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* style: Remove unused vars.
* feat: Transformers now have the option to have an invariant target type.
* fix: Wrong service id for `CopyTransformer`.
* fix: Remove cache file & regenerate it if it is corrupt.

## 0.5.8

Expand Down
10 changes: 8 additions & 2 deletions src/Mapping/CachingMappingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ public function getMapping(): Mapping
return $this->warmUpAndGetMapping();
}

/** @psalm-suppress UnresolvableInclude */
$result = require $this->getCacheFilePath();
try {
/** @psalm-suppress UnresolvableInclude */
$result = require $this->getCacheFilePath();
} catch (\Throwable) {
unlink($this->getCacheFilePath());

return $this->warmUpAndGetMapping();
}

if (!$result instanceof Mapping) {
unlink($this->getCacheFilePath());
Expand Down

0 comments on commit b6b1cf6

Please sign in to comment.