perf(UserMountCache): Start transaction earlier to prevent unnecessary queries

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/56933/head
provokateurin 2025-12-09 13:26:06 +07:00
parent 6ace53c5b1
commit 91b06a8be0
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

@ -70,6 +70,8 @@ class UserMountCache implements IUserMountCache {
}
}
$this->connection->beginTransaction();
$cachedMounts = $this->getMountsForUser($user);
if (is_array($mountProviderClasses)) {
$cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) {
@ -100,7 +102,6 @@ class UserMountCache implements IUserMountCache {
$changedMounts = $this->findChangedMounts($newMounts, $cachedMounts);
if ($addedMounts || $removedMounts || $changedMounts) {
$this->connection->beginTransaction();
$userUID = $user->getUID();
try {
foreach ($addedMounts as $mount) {
@ -137,7 +138,11 @@ class UserMountCache implements IUserMountCache {
foreach ($changedMounts as $mountPair) {
$this->eventDispatcher->dispatchTyped(new UserMountUpdatedEvent($mountPair[0], $mountPair[1]));
}
} else {
// No changes were made, but we still need to get rid of the transaction
$this->connection->rollBack();
}
$this->eventLogger->end('fs:setup:user:register');
}