[Bridge] Rename to
This commit is contained in:
parent
56cb116ce6
commit
458d1fbfeb
1 changed files with 21 additions and 21 deletions
|
@ -172,20 +172,20 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
|
|
||||||
// TODO build this from the variable given to Cache
|
// TODO build this from the variable given to Cache
|
||||||
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
||||||
$filename = $pageCacheDir . $simplified_url;
|
$filepath = $pageCacheDir . $simplified_url;
|
||||||
|
|
||||||
if(substr($filename, -1) == '/'){
|
if(substr($filepath, -1) == '/'){
|
||||||
$filename = $filename . 'index.html';
|
$filepath .= 'index.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($filename)){
|
if(file_exists($filepath)){
|
||||||
$this->debugMessage('loading cached file from ' . $filename . ' for page at url ' . $url);
|
$this->debugMessage('loading cached file from ' . $filepath . ' for page at url ' . $url);
|
||||||
// TODO touch file and its parent, and try to do neighbour deletion
|
// TODO touch file and its parent, and try to do neighbour deletion
|
||||||
$this->refresh_in_cache($pageCacheDir, $filename);
|
$this->refresh_in_cache($pageCacheDir, $filepath);
|
||||||
$content = file_get_contents($filename);
|
$content = file_get_contents($filepath);
|
||||||
} else {
|
} else {
|
||||||
$this->debugMessage('we have no local copy of ' . $url . ' Downloading to ' . $filename);
|
$this->debugMessage('we have no local copy of ' . $url . ' Downloading to ' . $filepath);
|
||||||
$dir = substr($filename, 0, strrpos($filename, '/'));
|
$dir = substr($filepath, 0, strrpos($filepath, '/'));
|
||||||
|
|
||||||
if(!is_dir($dir)){
|
if(!is_dir($dir)){
|
||||||
$this->debugMessage('creating directories for ' . $dir);
|
$this->debugMessage('creating directories for ' . $dir);
|
||||||
|
@ -194,7 +194,7 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
|
|
||||||
$content = $this->getContents($url);
|
$content = $this->getContents($url);
|
||||||
if($content !== false){
|
if($content !== false){
|
||||||
file_put_contents($filename,$content);
|
file_put_contents($filepath, $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,21 +206,21 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
|
|
||||||
// TODO build this from the variable given to Cache
|
// TODO build this from the variable given to Cache
|
||||||
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
||||||
$filename = $pageCacheDir . $simplified_url;
|
$filepath = $pageCacheDir . $simplified_url;
|
||||||
|
|
||||||
if(substr($filename, -1) == '/'){
|
if(substr($filepath, -1) == '/'){
|
||||||
$filename = $filename . 'index.html';
|
$filepath .= 'index.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!file_exists($filename)){
|
if(!file_exists($filepath)){
|
||||||
$this->get_cached($url);
|
$this->get_cached($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filectime($filename);
|
return filectime($filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function refresh_in_cache($pageCacheDir, $filename){
|
private function refresh_in_cache($pageCacheDir, $filepath){
|
||||||
$currentPath = $filename;
|
$currentPath = $filepath;
|
||||||
while(!$pageCacheDir == $currentPath){
|
while(!$pageCacheDir == $currentPath){
|
||||||
touch($currentPath);
|
touch($currentPath);
|
||||||
$currentPath = dirname($currentPath);
|
$currentPath = dirname($currentPath);
|
||||||
|
@ -232,9 +232,9 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
|
|
||||||
// TODO build this from the variable given to Cache
|
// TODO build this from the variable given to Cache
|
||||||
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
$pageCacheDir = __DIR__ . '/../cache/pages/';
|
||||||
$filename = realpath($pageCacheDir . $simplified_url);
|
$filepath = realpath($pageCacheDir . $simplified_url);
|
||||||
$this->debugMessage('removing from cache \'' . $filename . '\' WELL, NOT REALLY');
|
$this->debugMessage('removing from cache \'' . $filepath . '\' WELL, NOT REALLY');
|
||||||
// unlink($filename);
|
// unlink($filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue