diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index d8de365fb..d888ec915 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -1199,7 +1199,9 @@ private function getAffectedUsersFromCachedMounts(int $fileId): array { 'provider' => str_replace('\\\\', '\\', $mount->getMountProvider()), 'path' => $mount->getPath(), 'visiblePath' => $this->getVisiblePath($mount->getPath()), - 'storageId' => $mount->getStorageId() + 'storageId' => $mount->getStorageId(), + 'internalPath' => $mount->getInternalPath(), + 'rootInternalPath' => $mount->getRootInternalPath(), ]; } @@ -1229,6 +1231,8 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array { return []; // if we have no access to RuleManager, we cannot filter unrelated users } + $groupFolderAclStatus = []; + /** @var \OCA\GroupFolders\ACL\Rule[] $rules */ $rules = $knownRules = $knownGroupRules = $usersToCheck = $cachedPath = []; foreach ($cachedMounts as $cachedMount) { @@ -1249,16 +1253,21 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array { if (!array_key_exists($cachedMount['visiblePath'], $knownRules[$storageId])) { // we need mountPoint and folderId to generate the correct path try { - $node = $this->rootFolder->get($fullPath); - $mountPoint = $node->getMountPoint(); + // only check for groupfolders + if (!str_starts_with($cachedMount['rootInternalPath'], '__groupfolders')) { + continue; + } - if (!$mountPoint instanceof \OCA\GroupFolders\Mount\GroupMountPoint - || !$folderManager->getFolderAclEnabled($mountPoint->getFolderId())) { + $folderId = (int)basename($cachedMount['rootInternalPath']); + if (!isset($groupFolderAclStatus[$folderId])) { + $groupFolderAclStatus[$folderId] = $folderManager->getFolderAclEnabled($folderId); + } + if (!$groupFolderAclStatus[$folderId]) { continue; // acl are disable } - $folderPath = $mountPoint->getSourcePath(); - $path = substr($fullPath, strlen($mountPoint->getMountPoint())); + $folderPath = '/' . $cachedMount['rootInternalPath']; + $path = $cachedMount['internalPath']; } catch (\Exception $e) { // in case of issue during the process, we can imagine the user have no access to the file $usersToCheck[] = $cachedMount['userId'];