fix: add optional user param to IUserMountCache::removeMount

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-04-09 18:35:30 +02:00
parent a1b4a6b6b7
commit aedc57afe7
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
4 changed files with 11 additions and 8 deletions

View file

@ -75,7 +75,7 @@ class MountCacheService implements IEventListener {
public function handleDeletedStorage(StorageConfig $storage): void {
foreach ($this->applicableHelper->getUsersForStorage($storage) as $user) {
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
}
}
@ -87,7 +87,7 @@ class MountCacheService implements IEventListener {
public function handleUpdatedStorage(StorageConfig $oldStorage, StorageConfig $newStorage): void {
foreach ($this->applicableHelper->diffApplicable($oldStorage, $newStorage) as $user) {
$this->userMountCache->removeMount($oldStorage->getMountPointForUser($user));
$this->userMountCache->removeMount($oldStorage->getMountPointForUser($user), $user);
}
foreach ($this->applicableHelper->diffApplicable($newStorage, $oldStorage) as $user) {
$this->registerForUser($user, $newStorage);
@ -156,7 +156,7 @@ class MountCacheService implements IEventListener {
$storages = $this->storagesService->getAllStoragesForGroup($group);
foreach ($storages as $storage) {
if (!$this->applicableHelper->isApplicableForUser($storage, $user)) {
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
}
}
}
@ -181,7 +181,7 @@ class MountCacheService implements IEventListener {
private function removeGroupFromStorage(StorageConfig $storage, IGroup $group): void {
foreach ($group->searchUsers('') as $user) {
if (!$this->applicableHelper->isApplicableForUser($storage, $user)) {
$this->userMountCache->removeMount($storage->getMountPointForUser($user));
$this->userMountCache->removeMount($storage->getMountPointForUser($user), $user);
}
}
}

View file

@ -85,7 +85,7 @@ class ShareRecipientUpdater {
* Process a single deleted share for a user
*/
public function updateForDeletedShare(IUser $user, IShare $share): void {
$this->userMountCache->removeMount($this->getMountPointFromTarget($user, $share->getTarget()));
$this->userMountCache->removeMount($this->getMountPointFromTarget($user, $share->getTarget()), $user);
}
/**
@ -96,7 +96,7 @@ class ShareRecipientUpdater {
if ($originalTarget != null) {
$newMountPoint = $this->getMountPointFromTarget($user, $share->getTarget());
$oldMountPoint = $this->getMountPointFromTarget($user, $originalTarget);
$this->userMountCache->removeMount($oldMountPoint);
$this->userMountCache->removeMount($oldMountPoint, $user);
$this->userMountCache->addMount($user, $newMountPoint, $share->getNode()->getData(), MountProvider::class);
} else {
$this->updateForUser($user);

View file

@ -520,10 +520,13 @@ class UserMountCache implements IUserMountCache {
return $result;
}
public function removeMount(string $mountPoint): void {
public function removeMount(string $mountPoint, ?IUser $user = null): void {
$query = $this->connection->getQueryBuilder();
$query->delete('mounts')
->where($query->expr()->eq('mount_point_hash', $query->createNamedParameter(hash('xxh128', $mountPoint))));
if ($user) {
$query->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($user->getUID())));
}
$query->executeStatement();
$parts = explode('/', $mountPoint);

View file

@ -139,7 +139,7 @@ interface IUserMountCache {
*
* @since 33.0.0
*/
public function removeMount(string $mountPoint): void;
public function removeMount(string $mountPoint, ?IUser $user = null): void;
/**
* Register a new mountpoint for a user