diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-01-20 12:40:57 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-20 16:32:56 +0100 |
commit | 8a4c0829fb79c1836962122be048c020b9f019b4 (patch) | |
tree | c26aedef7646d65e6a74033a91893ca549739ea2 /lib/private/files/config/usermountcache.php | |
parent | 483c6b68e2797a4608f5ff519ba961facdf8e9e4 (diff) | |
download | nextcloud-server-8a4c0829fb79c1836962122be048c020b9f019b4.tar.gz nextcloud-server-8a4c0829fb79c1836962122be048c020b9f019b4.zip |
use insertifnotexists
Diffstat (limited to 'lib/private/files/config/usermountcache.php')
-rw-r--r-- | lib/private/files/config/usermountcache.php | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/lib/private/files/config/usermountcache.php b/lib/private/files/config/usermountcache.php index 5fa192d1054..e3a494e93a1 100644 --- a/lib/private/files/config/usermountcache.php +++ b/lib/private/files/config/usermountcache.php @@ -119,30 +119,12 @@ class UserMountCache implements IUserMountCache { } private function addToCache(ICachedMountInfo $mount) { - $builder = $this->connection->getQueryBuilder(); - - $query = $builder->insert('mounts') - ->values([ - 'storage_id' => ':storage', - 'root_id' => ':root', - 'user_id' => ':user', - 'mount_point' => ':mount' - ]); - $query->setParameters([ - ':storage' => $mount->getStorageId(), - ':root' => $mount->getRootId(), - ':user' => $mount->getUser()->getUID(), - ':mount' => $mount->getMountPoint() + $this->connection->insertIfNotExist('*PREFIX*mounts', [ + 'storage_id' => $mount->getStorageId(), + 'root_id' => $mount->getRootId(), + 'user_id' => $mount->getUser()->getUID(), + 'mount_point' => $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) { |