summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-12-01 12:41:48 +0100
committerRobin Appelman <icewind@owncloud.com>2016-01-20 16:30:22 +0100
commit89404299761c8f294e5cdbdc2f72c1b144be0ce0 (patch)
treee1c1febc07732da0e01486acadb979f50bd7ebf5 /lib/private
parentf986fb99f21f7d42bc4386b67638201afc339b8f (diff)
downloadnextcloud-server-89404299761c8f294e5cdbdc2f72c1b144be0ce0.tar.gz
nextcloud-server-89404299761c8f294e5cdbdc2f72c1b144be0ce0.zip
log duplicates
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/config/usermountcache.php19
-rw-r--r--lib/private/server.php2
2 files changed, 18 insertions, 3 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) {
diff --git a/lib/private/server.php b/lib/private/server.php
index 634de4ab1aa..e3a303b84eb 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -407,7 +407,7 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerService('MountConfigManager', function (Server $c) {
$loader = \OC\Files\Filesystem::getLoader();
- $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager());
+ $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
return new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
});
$this->registerService('IniWrapper', function ($c) {