Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] preload the acl rules for the root of the groupfolders #2462

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading