summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Config/UserMountCache.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-04-21 11:30:49 +0200
committerJoas Schilling (Rebase PR Action) <nickvergessen@users.noreply.github.com>2023-03-07 19:58:55 +0000
commit6b0cef6b9ad1afe1dbabcd5b85d4ef138c1c9a21 (patch)
tree4f65f0fa5f81723961830382db2baeeb09d81da7 /lib/private/Files/Config/UserMountCache.php
parent55db9780900a848d92af16d4ee1e762a1bfa33b2 (diff)
downloadnextcloud-server-6b0cef6b9ad1afe1dbabcd5b85d4ef138c1c9a21.tar.gz
nextcloud-server-6b0cef6b9ad1afe1dbabcd5b85d4ef138c1c9a21.zip
Add transaction around mass mounts operations
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Files/Config/UserMountCache.php')
-rw-r--r--lib/private/Files/Config/UserMountCache.php31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php
index fe677c5ea52..a60b39823c5 100644
--- a/lib/private/Files/Config/UserMountCache.php
+++ b/lib/private/Files/Config/UserMountCache.php
@@ -130,18 +130,25 @@ class UserMountCache implements IUserMountCache {
$changedMounts = $this->findChangedMounts($newMounts, $cachedMounts);
- foreach ($addedMounts as $mount) {
- $this->addToCache($mount);
- /** @psalm-suppress InvalidArgument */
- $this->mountsForUsers[$user->getUID()][] = $mount;
- }
- foreach ($removedMounts as $mount) {
- $this->removeFromCache($mount);
- $index = array_search($mount, $this->mountsForUsers[$user->getUID()]);
- unset($this->mountsForUsers[$user->getUID()][$index]);
- }
- foreach ($changedMounts as $mount) {
- $this->updateCachedMount($mount);
+ $this->connection->beginTransaction();
+ try {
+ foreach ($addedMounts as $mount) {
+ $this->addToCache($mount);
+ /** @psalm-suppress InvalidArgument */
+ $this->mountsForUsers[$user->getUID()][] = $mount;
+ }
+ foreach ($removedMounts as $mount) {
+ $this->removeFromCache($mount);
+ $index = array_search($mount, $this->mountsForUsers[$user->getUID()]);
+ unset($this->mountsForUsers[$user->getUID()][$index]);
+ }
+ foreach ($changedMounts as $mount) {
+ $this->updateCachedMount($mount);
+ }
+ $this->connection->commit();
+ } catch (\Throwable $e) {
+ $this->connection->rollBack();
+ throw $e;
}
$this->eventLogger->end('fs:setup:user:register');
}