mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #32038 from nextcloud/bugfix/noid/only-update-indexes-after-changing-all-mounts
Add transaction around mass mounts operations
This commit is contained in:
commit
11a0cb7f22
1 changed files with 19 additions and 12 deletions
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue