mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Add transaction around mass mounts operations
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
55db978090
commit
6b0cef6b9a
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