1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Don't write if already cached

This commit is contained in:
Matthew Brown 2016-01-08 10:47:15 -05:00
parent 8701c6a26e
commit d0afcddf57

View File

@ -92,6 +92,8 @@ class FileChecker
$stmts = []; $stmts = [];
$from_cache = false;
if (self::$_cache_dir) { if (self::$_cache_dir) {
$key = md5($contents); $key = md5($contents);
@ -99,6 +101,7 @@ class FileChecker
if (is_readable($cache_location)) { if (is_readable($cache_location)) {
$stmts = unserialize(file_get_contents($cache_location)); $stmts = unserialize(file_get_contents($cache_location));
$from_cache = true;
} }
} }
@ -109,11 +112,16 @@ class FileChecker
} }
if (self::$_cache_dir) { if (self::$_cache_dir) {
if (!file_exists(self::$_cache_dir)) { if ($from_cache) {
mkdir(self::$_cache_dir); touch($cache_location);
} }
else {
if (!file_exists(self::$_cache_dir)) {
mkdir(self::$_cache_dir);
}
file_put_contents($cache_location, serialize($stmts)); file_put_contents($cache_location, serialize($stmts));
}
} }
return $stmts; return $stmts;