From 2d68c1b9450d77d21b08fc66436d286996583589 Mon Sep 17 00:00:00 2001
From: Lukas Reschke <lukas@owncloud.com>
Date: Tue, 1 Mar 2016 17:16:10 +0100
Subject: [PATCH] Exclude custom data directory from integrity checker

We should not scan any custom data directory in the integrity checker as well. Otherwise this would lead to a massive increased update time that may likely exceed the timeout.

To test this:

1. Install ownCloud 8.2.2, set as data dir another folder than `data` such as `data-asdf`. Make sure that folder lives in the web root as well.
2. Update that instance to 9.0.0 beta2 => Errors are shown in the code integrity check
3. Apply this patch and trigger the rescan in the admin settings => No errors are shown anymore (can also do a new update with that patch applied)

Fixes https://github.com/owncloud/core/issues/22698
---
 .../iterator/excludefoldersbypathfilteriterator.php    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php
index 67bcd423b6..fc261e4bc5 100644
--- a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php
+++ b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php
@@ -32,12 +32,18 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator {
 			$appFolders[$key] = rtrim($appFolder['path'], '/');
 		}
 
-		$this->excludedFolders = array_merge([
+		$excludedFolders = [
 			rtrim($root . '/data', '/'),
 			rtrim($root .'/themes', '/'),
 			rtrim($root.'/config', '/'),
 			rtrim($root.'/apps', '/'),
-		], $appFolders);
+		];
+		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
+		if($customDataDir !== '') {
+			$excludedFolders[] = rtrim($customDataDir, '/');
+		}
+
+		$this->excludedFolders = array_merge($excludedFolders, $appFolders);
 	}
 
 	/**
-- 
GitLab