From f3e5211ed526cf07ffafdf2793779dba9360fc52 Mon Sep 17 00:00:00 2001 From: Diederik de Groot Date: Tue, 18 Feb 2020 04:00:58 +0100 Subject: [PATCH] Check cache for duplicate files when adding and report Signed-off-by: Diederik de Groot --- lib/resolveCache.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/resolveCache.php b/lib/resolveCache.php index 4613684..76c54fa 100644 --- a/lib/resolveCache.php +++ b/lib/resolveCache.php @@ -36,24 +36,26 @@ class fileCache extends resolveCache { return $this->_isDirty; } + public function check($filename) { + return array_key_exists($filename, $this->_cache); + } + public function addFile($filename, $realpath) { + if ($this->check($filename)) + log_error("Duplicate file:$filename"); /* should we prevent this ? */ $this->_cache[$filename] = $realpath; $this->_isDirty =true; } public function removeFile($filename) { - if (array_key_exists($filename, $this->_cache)) { + if ($this->check($filename)) { unset($this->_cache[$filename]); $this->_isDirty = true; } } - - public function check($filename) { - return array_key_exists($filename, $this->_cache); - } - + public function getPath($filename) { - if (array_key_exists($filename, $this->_cache)) { + if ($this->check($filename)) { return $this->_cache[$filename]; } return false;