|
|
|
@ -71,12 +71,14 @@ class Cache
|
|
|
|
|
|
|
|
|
|
public function read($file)
|
|
|
|
|
{
|
|
|
|
|
if ($this->enabled) {
|
|
|
|
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
|
|
|
|
if ($this->enabled && file_exists($this->root . $file)) {
|
|
|
|
|
if (file_exists($this->root . $file)) {
|
|
|
|
|
$this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
|
|
|
|
|
|
|
|
|
|
return file_get_contents($this->root . $file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -142,8 +144,9 @@ class Cache
|
|
|
|
|
*/
|
|
|
|
|
public function copyTo($file, $target)
|
|
|
|
|
{
|
|
|
|
|
if ($this->enabled) {
|
|
|
|
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
|
|
|
|
if ($this->enabled && file_exists($this->root . $file)) {
|
|
|
|
|
if (file_exists($this->root . $file)) {
|
|
|
|
|
try {
|
|
|
|
|
touch($this->root . $file, filemtime($this->root . $file), time());
|
|
|
|
|
} catch (\ErrorException $e) {
|
|
|
|
@ -156,6 +159,7 @@ class Cache
|
|
|
|
|
|
|
|
|
|
return copy($this->root . $file, $target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -167,10 +171,12 @@ class Cache
|
|
|
|
|
|
|
|
|
|
public function remove($file)
|
|
|
|
|
{
|
|
|
|
|
if ($this->enabled) {
|
|
|
|
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
|
|
|
|
if ($this->enabled && file_exists($this->root . $file)) {
|
|
|
|
|
if (file_exists($this->root . $file)) {
|
|
|
|
|
return $this->filesystem->unlink($this->root . $file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -216,20 +222,24 @@ class Cache
|
|
|
|
|
|
|
|
|
|
public function sha1($file)
|
|
|
|
|
{
|
|
|
|
|
if ($this->enabled) {
|
|
|
|
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
|
|
|
|
if ($this->enabled && file_exists($this->root . $file)) {
|
|
|
|
|
if (file_exists($this->root . $file)) {
|
|
|
|
|
return sha1_file($this->root . $file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function sha256($file)
|
|
|
|
|
{
|
|
|
|
|
if ($this->enabled) {
|
|
|
|
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
|
|
|
|
if ($this->enabled && file_exists($this->root . $file)) {
|
|
|
|
|
if (file_exists($this->root . $file)) {
|
|
|
|
|
return hash_file('sha256', $this->root . $file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|