mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 19:41:36 +01:00
implement ignore for backups
This commit is contained in:
@@ -14,6 +14,13 @@ class ZipBackup
|
||||
{
|
||||
use GravTrait;
|
||||
|
||||
protected static $ignore = [
|
||||
'.git',
|
||||
'cache',
|
||||
'images',
|
||||
'logs'
|
||||
];
|
||||
|
||||
public static function backup($destination = null, callable $messager = null)
|
||||
{
|
||||
if (!$destination) {
|
||||
@@ -43,7 +50,6 @@ class ZipBackup
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($destination, \ZipArchive::CREATE);
|
||||
$zip->addEmptyDir($name);
|
||||
|
||||
static::folderToZip(GRAV_ROOT, $zip, strlen(rtrim(GRAV_ROOT, DS) . DS), $messager);
|
||||
|
||||
@@ -83,6 +89,11 @@ class ZipBackup
|
||||
$filePath = "$folder/$f";
|
||||
// Remove prefix from file path before add to zip.
|
||||
$localPath = substr($filePath, $exclusiveLength);
|
||||
|
||||
if (in_array($localPath, static::$ignore)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_file($filePath)) {
|
||||
$zipFile->addFile($filePath, $localPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user