diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-01 12:41:48 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-20 16:30:22 +0100 |
commit | 89404299761c8f294e5cdbdc2f72c1b144be0ce0 (patch) | |
tree | e1c1febc07732da0e01486acadb979f50bd7ebf5 /lib/private/files/config/usermountcache.php | |
parent | f986fb99f21f7d42bc4386b67638201afc339b8f (diff) | |
download | nextcloud-server-89404299761c8f294e5cdbdc2f72c1b144be0ce0.tar.gz nextcloud-server-89404299761c8f294e5cdbdc2f72c1b144be0ce0.zip |
log duplicates
Diffstat (limited to 'lib/private/files/config/usermountcache.php')
-rw-r--r-- | lib/private/files/config/usermountcache.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/private/files/config/usermountcache.php b/lib/private/files/config/usermountcache.php index af4fe6488d4..444c59bb603 100644 --- a/lib/private/files/config/usermountcache.php +++ b/lib/private/files/config/usermountcache.php @@ -21,11 +21,13 @@ namespace OC\Files\Config; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\IUserMountCache; use OCP\Files\Mount\IMountPoint; use OCP\ICache; use OCP\IDBConnection; +use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; @@ -44,14 +46,21 @@ class UserMountCache implements IUserMountCache { private $mountsForUsers = []; /** + * @var ILogger + */ + private $logger; + + /** * UserMountCache constructor. * * @param IDBConnection $connection * @param IUserManager $userManager + * @param ILogger $logger */ - public function __construct(IDBConnection $connection, IUserManager $userManager) { + public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { $this->connection = $connection; $this->userManager = $userManager; + $this->logger = $logger; } public function registerMounts(IUser $user, array $mounts) { @@ -108,7 +117,13 @@ class UserMountCache implements IUserMountCache { ':user' => $mount->getUser()->getUID(), ':mount' => $mount->getMountPoint() ]); - $query->execute(); + try { + $query->execute(); + } catch (UniqueConstraintViolationException $e) { + // seems to mainly happen in tests + $this->logger->error('Duplicate entry while inserting mount'); + $this->logger->logException($e); + } } private function removeFromCache(ICachedMountInfo $mount) { |