Check cache for duplicate files when adding and report

Signed-off-by: Diederik de Groot <ddegroot@talon.nl>
This commit is contained in:
Diederik de Groot
2020-02-18 04:00:58 +01:00
parent 0ce2a149fc
commit f3e5211ed5

View File

@@ -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;