Commit 8a4c0829 authored by Robin Appelman's avatar Robin Appelman
Browse files

use insertifnotexists

parent 483c6b68
...@@ -119,30 +119,12 @@ class UserMountCache implements IUserMountCache { ...@@ -119,30 +119,12 @@ class UserMountCache implements IUserMountCache {
} }
private function addToCache(ICachedMountInfo $mount) { private function addToCache(ICachedMountInfo $mount) {
$builder = $this->connection->getQueryBuilder(); $this->connection->insertIfNotExist('*PREFIX*mounts', [
'storage_id' => $mount->getStorageId(),
$query = $builder->insert('mounts') 'root_id' => $mount->getRootId(),
->values([ 'user_id' => $mount->getUser()->getUID(),
'storage_id' => ':storage', 'mount_point' => $mount->getMountPoint()
'root_id' => ':root',
'user_id' => ':user',
'mount_point' => ':mount'
]);
$query->setParameters([
':storage' => $mount->getStorageId(),
':root' => $mount->getRootId(),
':user' => $mount->getUser()->getUID(),
':mount' => $mount->getMountPoint()
]); ]);
try {
$query->execute();
} catch (UniqueConstraintViolationException $e) {
// seems to mainly happen in tests
// can also happen during concurrent access but we can safely ignore it
// since inserting the same data twice will still result in the correct data being inserted
$this->logger->error('Duplicate entry while inserting mount');
$this->logger->logException($e);
}
} }
private function setMountPoint(ICachedMountInfo $mount) { private function setMountPoint(ICachedMountInfo $mount) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment