Skip to content

Commit be3bbf2

Browse files
committed
fix: better applicable check for updating external mounts
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent c14948f commit be3bbf2

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

apps/files_external/lib/Service/MountCacheService.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,26 @@ private function registerForUser(IUser $user, StorageConfig $storage): void {
194194
);
195195
}
196196

197+
private function isApplicableForUser(StorageConfig $storage, IUser $user): bool {
198+
if (count($storage->getApplicableUsers()) + count($storage->getApplicableGroups()) === 0) {
199+
return true;
200+
}
201+
if (in_array($user->getUID(), $storage->getApplicableUsers())) {
202+
return true;
203+
}
204+
$groupIds = $this->groupManager->getUserGroupIds($user);
205+
foreach ($groupIds as $groupId) {
206+
if (in_array($groupId, $storage->getApplicableGroups())) {
207+
return true;
208+
}
209+
}
210+
return false;
211+
}
212+
197213
private function handleUserRemoved(IGroup $group, IUser $user): void {
198214
$storages = $this->storagesService->getAllStoragesForGroup($group);
199215
foreach ($storages as $storage) {
200-
if (!in_array($user->getUID(), $storage->getApplicableUsers())) {
216+
if (!$this->isApplicableForUser($storage, $user)) {
201217
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
202218
}
203219
}
@@ -214,7 +230,7 @@ private function handleGroupDeleted(IGroup $group): void {
214230
$storages = $this->storagesService->getAllStoragesForGroup($group);
215231
foreach ($storages as $storage) {
216232
foreach ($group->searchUsers('') as $user) {
217-
if (!in_array($user->getUID(), $storage->getApplicableUsers())) {
233+
if (!$this->isApplicableForUser($storage, $user)) {
218234
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
219235
}
220236
}

0 commit comments

Comments
 (0)