Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-04-21 12:30:49 +0300
committerJoas Schilling <coding@schilljs.com>2022-07-08 11:55:44 +0300
commite4e8033cf6ddbc7a00fe121d15e3fecb37bb55c2 (patch)
tree1213af7f020418ddc8ceeb57f01efb1bae503a5c
parent3dfb5c9d75ccfb5c9442e88b1bf2a4ff191783dc (diff)
Add transaction around mass mounts operationsbugfix/noid/only-update-indexes-after-changing-all-mounts
Signed-off-by: Joas Schilling <coding@schilljs.com>
-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 c326eeb0b6c..4e5dd39de4f 100644
--- a/lib/private/Files/Config/UserMountCache.php
+++ b/lib/private/Files/Config/UserMountCache.php
@@ -116,18 +116,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;
}
}