From 1deb85bd329adcf727492fe0d561e613b5317992 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 15 Aug 2018 18:45:05 +0800 Subject: [PATCH] sync --- Asset.php | 32 +++++++++++++++++++++++++++----- UpdateDatabase.php | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Asset.php b/Asset.php index 2b80a923..c090c10b 100644 --- a/Asset.php +++ b/Asset.php @@ -36,6 +36,13 @@ class Pman_Core_Asset extends Pman { function get($s='', $opts = Array()) { + if( + !empty($_REQUEST['_clear_cache']) && + !empty($_REQUEST['_clear_module']) + ) { + $this->clearCompiledFilesCache($_REQUEST['_clear_module']); + } + $this->sessionState(0); @@ -115,11 +122,12 @@ class Pman_Core_Asset extends Pman { exit; } + function post($s='') { die('invalid'); } - static function getCompileDir($type) + static function getCompileDir($type, $module = '', $is_mkdir = true) { $ff = HTML_FlexyFramework::get(); @@ -127,12 +135,14 @@ class Pman_Core_Asset extends Pman { $compile_dir = session_save_path() . "/"; + $module = (empty($module)) ? $ff->project : $module; + switch($type) { case 'js': case 'css': $compile_dir .= implode("-", array( $ui['name'], - $ff->project, + $module, $ff->version, "{$type}compile" )); @@ -146,6 +156,10 @@ class Pman_Core_Asset extends Pman { return $compile_dir; } + if(!$is_mkdir) { + return false; + } + if(mkdir($compile_dir, 0700, true)) { return $compile_dir; } @@ -153,10 +167,18 @@ class Pman_Core_Asset extends Pman { return false; } - function clearCompiledFilesCache() + function clearCompiledFilesCache($module) { - // using getCompileDir.. + $compile_dir = $this->getCompileDir('js', $module, false); + + if(empty($compile_dir)) { + $this->jok('EMPTY'); + } + + foreach(glob($compile_dir.'/*.*') as $v){ + unlink($v); + } - return; + $this->jok('DONE'); } } diff --git a/UpdateDatabase.php b/UpdateDatabase.php index 4d142aae..5060eeee 100644 --- a/UpdateDatabase.php +++ b/UpdateDatabase.php @@ -215,6 +215,8 @@ class Pman_Core_UpdateDatabase extends Pman $this->runExtensions(); $this->clearApacheDataobjectsCache(); + + $this->clearCompileFileCache(); } function output() { @@ -1240,6 +1242,35 @@ class Pman_Core_UpdateDatabase extends Pman return $response; } - + function clearCompileFileCache() + { + $a = new Pman(); + $mods = $a->modulesList(); + + $url = "http://localhost{$this->local_base_url}/Core/Asset"; + + foreach ($mods as $mod) { + + $response = $this->curl($url, array( + '_clear_cache' => 1, + '_clear_module' => $mod + )); + + $json = json_decode($response, true); + + if( + empty($json['data']) || + ( + $json['data'] != 'DONE' && + $json['data'] != 'EMPTY' + ) + ){ + echo $response. "\n"; + echo "CURL clear compiled file failed\n"; + exit; + } + } + + } } -- 2.39.2