From cc4bb962a63483be97ccd243bee022816d1bbb9e Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 14 May 2015 17:33:54 +0200 Subject: [PATCH] Add non-public cache. --- src/_h5ai/backend/cache/README.md | 9 +++++++++ src/_h5ai/backend/php/core/class-setup.php | 14 +++++++++----- src/_h5ai/backend/php/ext/class-thumb.php | 6 +++--- src/_h5ai/public/cache/README.md | 2 ++ src/_h5ai/public/js/inc/main/info.js | 9 +++++++-- 5 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 src/_h5ai/backend/cache/README.md diff --git a/src/_h5ai/backend/cache/README.md b/src/_h5ai/backend/cache/README.md new file mode 100644 index 00000000..60bc4167 --- /dev/null +++ b/src/_h5ai/backend/cache/README.md @@ -0,0 +1,9 @@ +# Cache + +Private cache. + +This directory is used for server side caching. To use caching make this +directory writable for your webserver. + +There is no critical data in here. You can savely remove any content. This +will clear the cache. diff --git a/src/_h5ai/backend/php/core/class-setup.php b/src/_h5ai/backend/php/core/class-setup.php index e21fcf5e..9ef1dc7d 100644 --- a/src/_h5ai/backend/php/core/class-setup.php +++ b/src/_h5ai/backend/php/core/class-setup.php @@ -111,14 +111,17 @@ class Setup { $this->set('PUBLIC_HREF', Util::normalize_path($this->get('APP_HREF') . '/public', true)); $this->set('INDEX_HREF', Util::normalize_path($this->get('APP_HREF') . '/public/index.php', false)); - $this->set('CACHE_HREF', Util::normalize_path($this->get('APP_HREF') . '/public/cache', true)); - $this->set('CACHE_PATH', Util::normalize_path($this->get('APP_PATH') . '/public/cache', false)); - $this->set('HAS_WRITABLE_CACHE', @is_writable($this->get('CACHE_PATH'))); + $this->set('CACHE_PUB_HREF', Util::normalize_path($this->get('APP_HREF') . '/public/cache', true)); + $this->set('CACHE_PUB_PATH', Util::normalize_path($this->get('APP_PATH') . '/public/cache', false)); + $this->set('HAS_WRITABLE_CACHE_PUB', @is_writable($this->get('CACHE_PUB_PATH'))); + + $this->set('CACHE_PRV_PATH', Util::normalize_path($this->get('APP_PATH') . '/backend/cache', false)); + $this->set('HAS_WRITABLE_CACHE_PRV', @is_writable($this->get('CACHE_PRV_PATH'))); } private function add_sys_cmd_checks() { - $cmds_cache_path = Util::normalize_path($this->get('CACHE_PATH') . '/cmds.json', false); + $cmds_cache_path = Util::normalize_path($this->get('CACHE_PRV_PATH') . '/cmds.json', false); $cmds = Util::load_commented_json($cmds_cache_path); if (sizeof($cmds) === 0 || $this->refresh) { @@ -165,7 +168,8 @@ class Setup { 'INDEX_HREF', - 'HAS_WRITABLE_CACHE', + 'HAS_WRITABLE_CACHE_PUB', + 'HAS_WRITABLE_CACHE_PRV', 'HAS_CMD_AVCONV', 'HAS_CMD_CONVERT', diff --git a/src/_h5ai/backend/php/ext/class-thumb.php b/src/_h5ai/backend/php/ext/class-thumb.php index 90c1875b..65ee9504 100644 --- a/src/_h5ai/backend/php/ext/class-thumb.php +++ b/src/_h5ai/backend/php/ext/class-thumb.php @@ -16,8 +16,8 @@ class Thumb { $this->context = $context; $this->setup = $context->get_setup(); - $this->thumbs_path = $this->setup->get('CACHE_PATH') . '/' . Thumb::$THUMB_CACHE; - $this->thumbs_href = $this->setup->get('CACHE_HREF') . Thumb::$THUMB_CACHE; + $this->thumbs_path = $this->setup->get('CACHE_PUB_PATH') . '/' . Thumb::$THUMB_CACHE; + $this->thumbs_href = $this->setup->get('CACHE_PUB_HREF') . Thumb::$THUMB_CACHE; if (!is_dir($this->thumbs_path)) { @mkdir($this->thumbs_path, 0755, true); @@ -27,7 +27,7 @@ class Thumb { public function thumb($type, $source_href, $width, $height) { $source_path = $this->context->to_path($source_href); - if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PATH'))) { + if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PUB_PATH'))) { return null; } diff --git a/src/_h5ai/public/cache/README.md b/src/_h5ai/public/cache/README.md index f0fbb3dc..fd2974c7 100644 --- a/src/_h5ai/public/cache/README.md +++ b/src/_h5ai/public/cache/README.md @@ -1,5 +1,7 @@ # Cache +Public cache. + This directory is used for server side caching. To use caching make this directory writable for your webserver. diff --git a/src/_h5ai/public/js/inc/main/info.js b/src/_h5ai/public/js/inc/main/info.js index b2ee6804..c4532845 100644 --- a/src/_h5ai/public/js/inc/main/info.js +++ b/src/_h5ai/public/js/inc/main/info.js @@ -81,8 +81,13 @@ modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], fu ); addTest( - 'Cache directory', 'Web server has write access', - setup.HAS_WRITABLE_CACHE + 'Public Cache directory', 'Web server has write access', + setup.HAS_WRITABLE_CACHE_PUB + ); + + addTest( + 'Private Cache directory', 'Web server has write access', + setup.HAS_WRITABLE_CACHE_PRV ); addTest(