Merge branch 'zentaopms_266_task_#77605' into 'master'

* Finish task #77605.

See merge request easycorp/zentaopms!6396
This commit is contained in:
王怡栋
2022-11-28 08:37:57 +00:00
2 changed files with 9 additions and 6 deletions
+6 -4
View File
@@ -18,10 +18,11 @@ class zfile
* @param string $to
* @param bool $logLevel
* @param string $logFile
* @param array $excludeFiles
* @access public
* @return array copied files, count, size or message.
*/
public function copyDir($from, $to, $logLevel = false, $logFile = '')
public function copyDir($from, $to, $logLevel = false, $logFile = '', $excludeFiles = array())
{
static $copiedFiles = array();
static $errorFiles = array();
@@ -46,7 +47,7 @@ class zfile
$entries = scandir($from);
foreach($entries as $entry)
{
if($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == '.git') continue;
if($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == '.git' or in_array($entry, $excludeFiles)) continue;
$fullEntry = $from . $entry;
if(is_file($fullEntry))
@@ -101,10 +102,11 @@ class zfile
* Get count.
*
* @param string $dir
* @param array $excludeFiles
* @access public
* @return int
*/
public function getCount($dir)
public function getCount($dir, $excludeFiles = array())
{
if(!file_exists($dir)) return 0;
if(is_file($dir)) return 1;
@@ -113,7 +115,7 @@ class zfile
$entries = scandir($dir);
foreach($entries as $entry)
{
if($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == '.git') continue;
if($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == '.git' or in_array($entry, $excludeFiles)) continue;
$fullEntry = $dir . '/' . $entry;
$count += $this->getCount($fullEntry);
+3 -2
View File
@@ -34,6 +34,7 @@ class backupModel extends model
public function backFile($backupFile)
{
$zfile = $this->app->loadClass('zfile');
$return = new stdclass();
$return->result = true;
$return->error = '';
@@ -42,10 +43,10 @@ class backupModel extends model
$tmpLogFile = $this->getTmpLogFile($backupFile);
$dataDir = $this->app->getAppRoot() . 'www/data/';
$count = $zfile->getCount($dataDir);
$count = $zfile->getCount($dataDir, array('course'));
file_put_contents($tmpLogFile, json_encode(array('allCount' => $count)));
$result = $zfile->copyDir($dataDir, $backupFile, $logLevel = false, $tmpLogFile);
$result = $zfile->copyDir($dataDir, $backupFile, $logLevel = false, $tmpLogFile, array('course'));
$this->processSummary($backupFile, $result['count'], $result['size'], $result['errorFiles'], $count);
unlink($tmpLogFile);