From 7025eeb91e5268201d05858446807b5166f0ee6d Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 28 Nov 2022 08:09:10 +0000 Subject: [PATCH] * Finish task #77605. --- lib/zfile/zfile.class.php | 10 ++++++---- module/backup/model.php | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/zfile/zfile.class.php b/lib/zfile/zfile.class.php index 4903d50df4..c2c0b3a4ac 100644 --- a/lib/zfile/zfile.class.php +++ b/lib/zfile/zfile.class.php @@ -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); diff --git a/module/backup/model.php b/module/backup/model.php index f6d3432609..e2346b008f 100644 --- a/module/backup/model.php +++ b/module/backup/model.php @@ -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);