From c481acbb7185c3a0408ade4cc8e7a8d83e07b8cb Mon Sep 17 00:00:00 2001 From: Gert Date: Mon, 27 Apr 2015 16:24:17 +0200 Subject: [PATCH] implement ignore for backups --- system/src/Grav/Common/Backup/ZipBackup.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Backup/ZipBackup.php b/system/src/Grav/Common/Backup/ZipBackup.php index 48991b7b5..cdef16efc 100644 --- a/system/src/Grav/Common/Backup/ZipBackup.php +++ b/system/src/Grav/Common/Backup/ZipBackup.php @@ -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);