Add non-public cache.

This commit is contained in:
Lars Jung 2015-05-14 17:33:54 +02:00
parent 0a3d085c5a
commit cc4bb962a6
5 changed files with 30 additions and 10 deletions

9
src/_h5ai/backend/cache/README.md vendored Normal file
View file

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

View file

@ -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',

View file

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

View file

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

View file

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