Skip to content

Commit 09bd8a2

Browse files
committed
perf(UserMountCache): Start transaction earlier to prevent unnecessary queries
Signed-off-by: provokateurin <[email protected]>
1 parent 8fcaaeb commit 09bd8a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/private/Files/Config/UserMountCache.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function registerMounts(IUser $user, array $mounts, ?array $mountProvider
7070
}
7171
}
7272

73+
$this->connection->beginTransaction();
74+
7375
$cachedMounts = $this->getMountsForUser($user);
7476
if (is_array($mountProviderClasses)) {
7577
$cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) {
@@ -100,7 +102,6 @@ public function registerMounts(IUser $user, array $mounts, ?array $mountProvider
100102
$changedMounts = $this->findChangedMounts($newMounts, $cachedMounts);
101103

102104
if ($addedMounts || $removedMounts || $changedMounts) {
103-
$this->connection->beginTransaction();
104105
$userUID = $user->getUID();
105106
try {
106107
foreach ($addedMounts as $mount) {
@@ -137,7 +138,11 @@ public function registerMounts(IUser $user, array $mounts, ?array $mountProvider
137138
foreach ($changedMounts as $mountPair) {
138139
$this->eventDispatcher->dispatchTyped(new UserMountUpdatedEvent($mountPair[0], $mountPair[1]));
139140
}
141+
} else {
142+
// No changes were made, but we still need to get rid of the transaction
143+
$this->connection->rollBack();
140144
}
145+
141146
$this->eventLogger->end('fs:setup:user:register');
142147
}
143148

0 commit comments

Comments
 (0)