Skip to content

Commit a9507b1

Browse files
authored
Merge 8674827 into b7789d0
2 parents b7789d0 + 8674827 commit a9507b1

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lib/FilesHooks.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,9 @@ private function getAffectedUsersFromCachedMounts(int $fileId): array {
12511251
'provider' => str_replace('\\\\', '\\', $mount->getMountProvider()),
12521252
'path' => $mount->getPath(),
12531253
'visiblePath' => $this->getVisiblePath($mount->getPath()),
1254-
'storageId' => $mount->getStorageId()
1254+
'storageId' => $mount->getStorageId(),
1255+
'internalPath' => $mount->getInternalPath(),
1256+
'rootInternalPath' => $mount->getRootInternalPath(),
12551257
];
12561258
}
12571259

@@ -1281,6 +1283,8 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
12811283
return []; // if we have no access to RuleManager, we cannot filter unrelated users
12821284
}
12831285

1286+
$groupFolderAclStatus = [];
1287+
12841288
/** @var \OCA\GroupFolders\ACL\Rule[] $rules */
12851289
$rules = $knownRules = $knownGroupRules = $usersToCheck = $cachedPath = [];
12861290
foreach ($cachedMounts as $cachedMount) {
@@ -1301,16 +1305,21 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
13011305
if (!array_key_exists($cachedMount['visiblePath'], $knownRules[$storageId])) {
13021306
// we need mountPoint and folderId to generate the correct path
13031307
try {
1304-
$node = $this->rootFolder->get($fullPath);
1305-
$mountPoint = $node->getMountPoint();
1308+
// only check for groupfolders
1309+
if (!str_starts_with($cachedMount['rootInternalPath'], '__groupfolders')) {
1310+
continue;
1311+
}
13061312

1307-
if (!$mountPoint instanceof \OCA\GroupFolders\Mount\GroupMountPoint
1308-
|| !$folderManager->getFolderAclEnabled($mountPoint->getFolderId())) {
1313+
$folderId = (int)basename($cachedMount['rootInternalPath']);
1314+
if (!isset($groupFolderAclStatus[$folderId])) {
1315+
$groupFolderAclStatus[$folderId] = $folderManager->getFolderAclEnabled($folderId);
1316+
}
1317+
if (!$groupFolderAclStatus[$folderId]) {
13091318
continue; // acl are disable
13101319
}
13111320

1312-
$folderPath = $mountPoint->getSourcePath();
1313-
$path = substr($fullPath, strlen($mountPoint->getMountPoint()));
1321+
$folderPath = '/' . $cachedMount['rootInternalPath'];
1322+
$path = $cachedMount['internalPath'];
13141323
} catch (\Exception $e) {
13151324
// in case of issue during the process, we can imagine the user have no access to the file
13161325
$usersToCheck[] = $cachedMount['userId'];

0 commit comments

Comments
 (0)