@@ -23,10 +23,10 @@ class fileCache extends resolveCache {
|
||||
|
||||
function __destruct() {
|
||||
if ($this->_isDirty) {
|
||||
if (!is_writable($this->_cache_file)) {
|
||||
/*if (!is_writable($this->_cache_file)) {
|
||||
log_error_and_throw("Could not write to file '".$this->_cache_file."' at Resolver::destruct");
|
||||
}
|
||||
if (!file_put_contents($this->_cache_file, serialize($this->cache))) {
|
||||
}*/
|
||||
if (!file_put_contents($this->_cache_file, serialize($this->_cache))) {
|
||||
log_error_and_throw("Could not write to file '".$this->_cache_file."' at Resolver::destruct");
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,6 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function searchForFile($filename) {
|
||||
foreach($this->config['subdirs'] as $key => $value) {
|
||||
if ($key === "firmware" || $key === "tftproot" ) {
|
||||
@@ -47,7 +46,7 @@ class Resolver {
|
||||
}
|
||||
$path = realpath($this->config['main']['base_path'] . "/" . $value['path'] . "/$filename");
|
||||
if (file_exists($path)) {
|
||||
$this-> addFile($filename, $path);
|
||||
$this->cache->addFile($filename, $path);
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +55,7 @@ class Resolver {
|
||||
}
|
||||
|
||||
public function rebuildCache() {
|
||||
log_debug("Rebuilding Cache, standby...");
|
||||
foreach($this->config['subdirs'] as $key =>$value) {
|
||||
if ($key === "tftproot") {
|
||||
continue;
|
||||
@@ -66,10 +66,10 @@ class Resolver {
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile()) {
|
||||
if ($value['strip']) {
|
||||
$this->addFile($file->getFileName(), $file->getPathname());
|
||||
$this->cache->addFile($file->getFileName(), $file->getPathname());
|
||||
} else {
|
||||
$subdir = basename(dirname($file->getPathname()));
|
||||
$this->addFile('$subpath/'.$file->getFileName(), $file->getPathname());
|
||||
$this->cache->addFile('$subpath/'.$file->getFileName(), $file->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,16 +77,6 @@ class Resolver {
|
||||
$this->isDirty = TRUE;
|
||||
}
|
||||
|
||||
public function addFile($requestpath, $truepath) {
|
||||
log_debug("Adding $requestpath");
|
||||
$this->cache->addFile($requestpath, $truepath);
|
||||
}
|
||||
|
||||
public function removeFile($requestpath) {
|
||||
log_debug("Removing $hash");
|
||||
$this->cache->removeFile($requestpath, $truepath);
|
||||
}
|
||||
|
||||
public function validateRequest($request) {
|
||||
/* make sure request does not startwith or contain: "/", "../" or "/./" */
|
||||
/* make sure request only starts with filename or one of $config[$subdir]['locale'] or $config[$subdir]['wallpaper'] */
|
||||
@@ -120,7 +110,7 @@ class Resolver {
|
||||
}
|
||||
if (($path = $this->cache->getPath($request))) {
|
||||
if (!file_exists($path)) {
|
||||
$this->removeFile($request);
|
||||
$this->cache->removeFile($request);
|
||||
log_error("File '$request' does not exist on FS");
|
||||
return ResolveResult::FileNotFound;
|
||||
}
|
||||
|
Reference in New Issue
Block a user