mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 05:54:48 -04:00
Add non-public cache.
This commit is contained in:
parent
0a3d085c5a
commit
cc4bb962a6
5 changed files with 30 additions and 10 deletions
9
src/_h5ai/backend/cache/README.md
vendored
Normal file
9
src/_h5ai/backend/cache/README.md
vendored
Normal 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.
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
2
src/_h5ai/public/cache/README.md
vendored
2
src/_h5ai/public/cache/README.md
vendored
|
@ -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.
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue