From: Marcin Haba Date: Sat, 6 Feb 2021 20:29:05 +0000 (+0100) Subject: baculum: Improve updating asset files after upgrade X-Git-Tag: Release-11.0.2~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28d1d24700544cba53611606041d28a1e00968a3;p=thirdparty%2Fbacula.git baculum: Improve updating asset files after upgrade --- diff --git a/gui/baculum/protected/Common/Class/BAssetManager.php b/gui/baculum/protected/Common/Class/BAssetManager.php new file mode 100644 index 000000000..1457771cb --- /dev/null +++ b/gui/baculum/protected/Common/Class/BAssetManager.php @@ -0,0 +1,94 @@ + original file MTIME + * + * and in real the original file MTIME has newer content than that one in + * asset directory. It is because copy() changes MTIME of destination file. + * + * @category Client Script + * @package Baculum Common + */ +class BAssetManager extends TAssetManager { + + protected function copyFile($src, $dst) { + if (!is_dir($dst)) { + @mkdir($dst); + @chmod($dst, PRADO_CHMOD); + } + $dst_file = $dst . DIRECTORY_SEPARATOR . basename($src); + $src_mtime = @filemtime($src); + if (@filemtime($dst_file) !== $src_mtime) { + @copy($src, $dst_file); + if ($src_mtime !== false) { + @touch($dst_file, $src_mtime); + } + } + } + + public function copyDirectory($src, $dst) { + if (!is_dir($dst)) { + @mkdir($dst); + @chmod($dst, PRADO_CHMOD); + } + if ($folder = @opendir($src)) { + while ($file = @readdir($folder)) { + $src_file = $src . DIRECTORY_SEPARATOR . $file; + $dst_file = $dst . DIRECTORY_SEPARATOR . $file; + if ($file === '.' || $file === '..') { + continue; + } elseif (is_file($src_file)) { + $src_mtime = @filemtime($src_file); + if (@filemtime($dst_file) !== $src_mtime) { + @copy($src_file, $dst_file); + if ($src_mtime !== false) { + @touch($dst_file, $src_mtime); + } + @chmod($dst_file, PRADO_CHMOD); + } + } else { + $this->copyDirectory($src_file, $dst_file); + } + } + closedir($folder); + } else { + throw new TInvalidDataValueException('assetmanager_source_directory_invalid', $src); + } + } +} +?> diff --git a/gui/baculum/protected/application.xml b/gui/baculum/protected/application.xml index ff55430f3..15ffd6680 100644 --- a/gui/baculum/protected/application.xml +++ b/gui/baculum/protected/application.xml @@ -8,6 +8,7 @@ +