Skip to content

Commit 954515d

Browse files
committed
fix: add optional user param to IUserMountCache::removeMount
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 81a642e commit 954515d

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

apps/files_external/lib/Service/MountCacheService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function handle(Event $event): void {
7575

7676
public function handleDeletedStorage(StorageConfig $storage): void {
7777
foreach ($this->applicableHelper->getUsersForStorage($storage) as $user) {
78-
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
78+
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
7979
}
8080
}
8181

@@ -87,7 +87,7 @@ public function handleAddedStorage(StorageConfig $storage): void {
8787

8888
public function handleUpdatedStorage(StorageConfig $oldStorage, StorageConfig $newStorage): void {
8989
foreach ($this->applicableHelper->diffApplicable($oldStorage, $newStorage) as $user) {
90-
$this->userMountCache->removeMount($oldStorage->getMountPointForUser($user));
90+
$this->userMountCache->removeMount($oldStorage->getMountPointForUser($user), $user);
9191
}
9292
foreach ($this->applicableHelper->diffApplicable($newStorage, $oldStorage) as $user) {
9393
$this->registerForUser($user, $newStorage);
@@ -156,7 +156,7 @@ private function handleUserRemoved(IGroup $group, IUser $user): void {
156156
$storages = $this->storagesService->getAllStoragesForGroup($group);
157157
foreach ($storages as $storage) {
158158
if (!$this->applicableHelper->isApplicableForUser($storage, $user)) {
159-
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
159+
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
160160
}
161161
}
162162
}
@@ -181,7 +181,7 @@ private function handleGroupDeleted(IGroup $group): void {
181181
private function removeGroupFromStorage(StorageConfig $storage, IGroup $group): void {
182182
foreach ($group->searchUsers('') as $user) {
183183
if (!$this->applicableHelper->isApplicableForUser($storage, $user)) {
184-
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
184+
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
185185
}
186186
}
187187
}

apps/files_sharing/lib/ShareRecipientUpdater.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function getMountPointFromTarget(IUser $user, string $target): string {
8585
* Process a single deleted share for a user
8686
*/
8787
public function updateForDeletedShare(IUser $user, IShare $share): void {
88-
$this->userMountCache->removeMount($this->getMountPointFromTarget($user, $share->getTarget()));
88+
$this->userMountCache->removeMount($this->getMountPointFromTarget($user, $share->getTarget()), $user);
8989
}
9090

9191
/**
@@ -96,7 +96,7 @@ public function updateForMovedShare(IUser $user, IShare $share): void {
9696
if ($originalTarget != null) {
9797
$newMountPoint = $this->getMountPointFromTarget($user, $share->getTarget());
9898
$oldMountPoint = $this->getMountPointFromTarget($user, $originalTarget);
99-
$this->userMountCache->removeMount($oldMountPoint);
99+
$this->userMountCache->removeMount($oldMountPoint, $user);
100100
$this->userMountCache->addMount($user, $newMountPoint, $share->getNode()->getData(), MountProvider::class);
101101
} else {
102102
$this->updateForUser($user);

lib/private/Files/Config/UserMountCache.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,13 @@ public function getMountsInPath(IUser $user, string $path): array {
519519
return $result;
520520
}
521521

522-
public function removeMount(string $mountPoint): void {
522+
public function removeMount(string $mountPoint, ?IUser $user = null): void {
523523
$query = $this->connection->getQueryBuilder();
524524
$query->delete('mounts')
525525
->where($query->expr()->eq('mount_point_hash', $query->createNamedParameter(hash('xxh128', $mountPoint))));
526+
if ($user) {
527+
$query->andWhere($query->expr()->eq('user', $query->createNamedParameter($user->getUID())));
528+
}
526529
$query->executeStatement();
527530

528531
$parts = explode('/', $mountPoint);

lib/public/Files/Config/IUserMountCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function getMountsInPath(IUser $user, string $path): array;
139139
*
140140
* @since 33.0.0
141141
*/
142-
public function removeMount(string $mountPoint): void;
142+
public function removeMount(string $mountPoint, ?IUser $user = null): void;
143143

144144
/**
145145
* Register a new mountpoint for a user

0 commit comments

Comments
 (0)