diff options
author | Romain Rivière <lecoyote@lecoyote.org> | 2018-03-05 09:27:34 +0100 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-02-14 11:48:09 +0100 |
commit | abb56c72e1d63fe0e70e82c2b12032e0f923d191 (patch) | |
tree | 5b212bc95034fd4602d9e3737d0d69a88b681bd7 /lib/private/IntegrityCheck | |
parent | 004f7fa8e141b159cc76f99cc041eec215444236 (diff) | |
download | nextcloud-server-abb56c72e1d63fe0e70e82c2b12032e0f923d191.tar.gz nextcloud-server-abb56c72e1d63fe0e70e82c2b12032e0f923d191.zip |
Exclude file name patterns; ignore gentoo webapp files
Signed-off-by: Romain Rivière <lecoyote@lecoyote.org>
Diffstat (limited to 'lib/private/IntegrityCheck')
-rw-r--r-- | lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php index e0ad6a550e5..c6017a0b243 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php @@ -26,7 +26,7 @@ namespace OC\IntegrityCheck\Iterator; /** * Class ExcludeFileByNameFilterIterator provides a custom iterator which excludes - * entries with the specified file name from the file list. + * entries with the specified file name from the file list. These file names are matched exactly. * * @package OC\Integritycheck\Iterator */ @@ -42,10 +42,21 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator { '.DS_Store', // Mac OS X 'Thumbs.db', // Microsoft Windows '.directory', // Dolphin (KDE) - '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps. + '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manage web-apps. ]; /** + * Array of excluded file name parts. Those are not scanned by the integrity checker. + * These strings are regular expressions and any file names + * matching these expressions are ignored. + * + * @var array + */ + private $excludedFileNamePatterns = [ + '/\.webapp-nextcloud-(\d+\.){3}(-r\d+)?/', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manage wep-apps. + ]; + + /** * @return bool */ public function accept() { @@ -53,10 +64,17 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator { return true; } - return !\in_array( - $this->current()->getFilename(), - $this->excludedFilenames, - true - ); + $currentFileName = $this->current()->getFilename(); + if (in_array($currentFileName, $this->excludedFilenames, true)){ + return false; + } + + foreach ($this->excludedFileNamePatterns as $pattern){ + if (preg_match($pattern, $currentFileName) > 0){ + return false; + } + } + + return true; } } |