From 4d3fa42716331db6a72307bb48ca2ea67cf86ba7 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 14 Sep 2023 10:27:47 +0200 Subject: [PATCH 1/3] show number of files and size in cache --- views/bootstrap/class.ClearCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.ClearCache.php b/views/bootstrap/class.ClearCache.php index 7f5736b7a..2710140da 100644 --- a/views/bootstrap/class.ClearCache.php +++ b/views/bootstrap/class.ClearCache.php @@ -63,7 +63,7 @@ class SeedDMS_View_ClearCache extends SeedDMS_Theme_Style { $addcache = array(); if($addcache = $this->callHook('additionalCache')) { foreach($addcache as $c) - echo "

".$c[1]."

"; + echo "

".$c[1].(isset($c[2])||isset($c[3]) ? "
" : '').(isset($c[2]) ? SeedDMS_Core_File::format_filesize($c[2]) : '').(isset($c[3]) ? ' in '.$c[3]." Files" : '')."

"; } $this->contentContainerEnd(); $this->formSubmit(" ".getMLText('clear_cache'), '', '', 'danger'); From c2a4c76f3f2c85b65090dab971ba3b303bcb2a38 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 14 Sep 2023 12:10:12 +0200 Subject: [PATCH 2/3] use DIRECTORY_SEPARATOR when building path to cache dir --- controllers/class.ClearCache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/class.ClearCache.php b/controllers/class.ClearCache.php index aef34fc5e..116079dfd 100644 --- a/controllers/class.ClearCache.php +++ b/controllers/class.ClearCache.php @@ -30,22 +30,22 @@ class SeedDMS_Controller_ClearCache extends SeedDMS_Controller_Common { $ret = ''; if(!empty($post['previewpng'])) { - $cmd = 'rm -rf '.$settings->_cacheDir.'/png/[1-9]*'; + $cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'png'.DIRECTORY_SEPARATOR.'[1-9]*'; system($cmd, $ret); } if(!empty($post['previewpdf'])) { - $cmd = 'rm -rf '.$settings->_cacheDir.'/pdf/[1-9]*'; + $cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'pdf'.DIRECTORY_SEPARATOR.'[1-9]*'; system($cmd, $ret); } if(!empty($post['previewtxt'])) { - $cmd = 'rm -rf '.$settings->_cacheDir.'/txt/[1-9]*'; + $cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'txt'.DIRECTORY_SEPARATOR.'[1-9]*'; system($cmd, $ret); } if(!empty($post['js'])) { - $cmd = 'rm -rf '.$settings->_cacheDir.'/js/*'; + $cmd = 'rm -rf '.addDirSep($settings->_cacheDir).'js'.DIRECTORY_SEPARATOR.'*'; system($cmd, $ret); } From 3e47e80874107081d98e3dea71b7f19aa117955b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 14 Sep 2023 12:10:34 +0200 Subject: [PATCH 3/3] =?UTF-8?q?calc=20and=20di=D1=95play=20disc=20usage=20?= =?UTF-8?q?and=20number=20of=20files=20in=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/bootstrap/class.ClearCache.php | 54 +++++++++++++++++++++------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/views/bootstrap/class.ClearCache.php b/views/bootstrap/class.ClearCache.php index 2710140da..3323f768e 100644 --- a/views/bootstrap/class.ClearCache.php +++ b/views/bootstrap/class.ClearCache.php @@ -31,6 +31,10 @@ */ class SeedDMS_View_ClearCache extends SeedDMS_Theme_Style { + protected function output($name, $title, $space, $c) { + echo '

'.$title.($space !== NULL || $c != NULL ? '
' : '').($space !== NULL ? SeedDMS_Core_File::format_filesize($space) : '').($c !== NULL ? ' in '.$c.' Files' : '').'

'; + } + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -48,24 +52,48 @@ class SeedDMS_View_ClearCache extends SeedDMS_Theme_Style { contentContainerStart('warning'); ?> -

- -

-

- -

-

- -

-

- output('preview', getMLText('preview_'.$t), $space, $c); + } + + /* Javascript */ + $path = addDirSep($cachedir).'js'; + if(file_exists($path)) { + $space = dskspace($path); + $fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS); + $c = iterator_count($fi); + } else { + $space = $c = 0; + } + $totalc += $c; + $totalspace += $space; + $this->output('js', getMLText('temp_jscode'), $space, $c); + + /* Cache dirŅ• added by extensions */ $addcache = array(); if($addcache = $this->callHook('additionalCache')) { - foreach($addcache as $c) - echo "

".$c[1].(isset($c[2])||isset($c[3]) ? "
" : '').(isset($c[2]) ? SeedDMS_Core_File::format_filesize($c[2]) : '').(isset($c[3]) ? ' in '.$c[3]." Files" : '')."

"; + foreach($addcache as $c) { + $this->output($c[0], $c[1], isset($c[2]) ? $c[2] : NULL, isset($c[3]) ? $c[3] : NULL); + $totalc += $c[3]; + $totalspace += $c[2]; + } } $this->contentContainerEnd(); + $this->infoMsg(SeedDMS_Core_File::format_filesize($totalspace).' in '.$totalc.' Files'); $this->formSubmit(" ".getMLText('clear_cache'), '', '', 'danger'); ?>