Add transaction around mass mounts operations

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/32038/head
Joas Schilling 2 years ago committed by Joas Schilling (Rebase PR Action)
parent 55db978090
commit 6b0cef6b9a

@ -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…
Cancel
Save