Skip to content

Commit

Permalink
preload the acl rules for the root of the groupfolders
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and backportbot-nextcloud[bot] committed Jul 11, 2023
1 parent fbd5bba commit 5659ad7
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OCA\GroupFolders\ACL\ACLManager;
use OCA\GroupFolders\ACL\ACLManagerFactory;
use OCA\GroupFolders\ACL\ACLStorageWrapper;
use OCA\GroupFolders\Folder\FolderManager;
Expand Down Expand Up @@ -130,7 +131,16 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
}, $folders);
$conflicts = $this->findConflictsForUser($user, $mountPoints);

return array_values(array_filter(array_map(function ($folder) use ($user, $loader, $conflicts) {
$foldersWithAcl = array_filter($folders, function(array $folder) {
return $folder['acl'];
});
$aclRootPaths = array_map(function(array $folder) {
return $this->getJailPath($folder['folder_id']);
}, $foldersWithAcl);
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
$aclManager->preloadPaths($aclRootPaths);

return array_values(array_filter(array_map(function ($folder) use ($user, $loader, $conflicts, $aclManager) {
// check for existing files in the user home and rename them if needed
$originalFolderName = $folder['mount_point'];
if (in_array($originalFolderName, $conflicts)) {
Expand All @@ -157,7 +167,8 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$folder['rootCacheEntry'],
$loader,
$folder['acl'],
$user
$user,
$aclManager
);
}, $folders)));
}
Expand All @@ -180,7 +191,20 @@ private function getCurrentUID(): ?string {
return $user ? $user->getUID() : null;
}

public function getMount(int $id, string $mountPoint, int $permissions, int $quota, ?ICacheEntry $cacheEntry = null, IStorageFactory $loader = null, bool $acl = false, IUser $user = null): ?IMountPoint {
public function getMount(
int $id,
string $mountPoint,
int $permissions,
int $quota,
?ICacheEntry $cacheEntry = null,
IStorageFactory $loader = null,
bool $acl = false,
IUser $user = null,
?ACLManager $aclManager = null
): ?IMountPoint {
if (!$aclManager) {
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
}
if (!$cacheEntry) {
// trigger folder creation
$folder = $this->getFolder($id);
Expand All @@ -197,7 +221,6 @@ public function getMount(int $id, string $mountPoint, int $permissions, int $quo
// apply acl before jail
if ($acl && $user) {
$inShare = $this->getCurrentUID() === null || $this->getCurrentUID() !== $user->getUID();
$aclManager = $this->aclManagerFactory->getACLManager($user, $this->getRootStorageId());
$storage = new ACLStorageWrapper([
'storage' => $storage,
'acl_manager' => $aclManager,
Expand Down

0 comments on commit 5659ad7

Please sign in to comment.