Skip to content

Commit

Permalink
[Caching] Fix cache consecutive run rector with --dry-run (#3060)
Browse files Browse the repository at this point in the history
* [Caching] Fix cache consecutive run rector with --dry-run

* resolve fiel path cache key

* Final touch: fallback when realpath is false

* Really final touch: phpstan

* Final touch: move resolve path to separate method to be used in hashFile()
  • Loading branch information
samsonasik committed Nov 13, 2022
1 parent 419c4f8 commit 2af8095
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/Caching/Detector/ChangedFilesDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,25 @@ public function setFirstResolvedConfigFileInfo(string $filePath): void
$this->storeConfigurationDataHash($filePath, $configHash);
}

private function resolvePath(string $filePath): string
{
$realPath = realpath($filePath);

if ($realPath === false) {
return $filePath;
}

return $realPath;
}

private function getFilePathCacheKey(string $filePath): string
{
return sha1($filePath);
return sha1($this->resolvePath($filePath));
}

private function hashFile(string $filePath): string
{
return (string) sha1_file($filePath);
return (string) sha1_file($this->resolvePath($filePath));
}

private function storeConfigurationDataHash(string $filePath, string $configurationHash): void
Expand Down

0 comments on commit 2af8095

Please sign in to comment.