|
28 | 28 | */
|
29 | 29 | namespace OC\Files\Config;
|
30 | 30 |
|
| 31 | +use OC\DB\Exceptions\DbalException; |
31 | 32 | use OCP\Cache\CappedMemoryCache;
|
32 | 33 | use OCP\DB\QueryBuilder\IQueryBuilder;
|
33 | 34 | use OCP\Diagnostics\IEventLogger;
|
@@ -172,14 +173,21 @@ private function findChangedMounts(array $newMounts, array $cachedMounts) {
|
172 | 173 |
|
173 | 174 | private function addToCache(ICachedMountInfo $mount) {
|
174 | 175 | if ($mount->getStorageId() !== -1) {
|
175 |
| - $this->connection->insertIfNotExist('*PREFIX*mounts', [ |
176 |
| - 'storage_id' => $mount->getStorageId(), |
177 |
| - 'root_id' => $mount->getRootId(), |
178 |
| - 'user_id' => $mount->getUser()->getUID(), |
179 |
| - 'mount_point' => $mount->getMountPoint(), |
180 |
| - 'mount_id' => $mount->getMountId(), |
181 |
| - 'mount_provider_class' => $mount->getMountProvider(), |
182 |
| - ], ['root_id', 'user_id', 'mount_point']); |
| 176 | + $query = $this->connection->getQueryBuilder(); |
| 177 | + $query->insert('mounts') |
| 178 | + ->values([ |
| 179 | + 'storage_id' => $query->createNamedParameter($mount->getStorageId(), IQueryBuilder::PARAM_INT), |
| 180 | + 'root_id' => $query->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT), |
| 181 | + 'user_id' => $query->createNamedParameter($mount->getUser()->getUID()), |
| 182 | + 'mount_point' => $query->createNamedParameter($mount->getMountPoint()), |
| 183 | + 'mount_id' => $query->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT), |
| 184 | + 'mount_provider_class' => $query->createNamedParameter($mount->getMountProvider()), |
| 185 | + ]); |
| 186 | + try { |
| 187 | + $query->executeStatement(); |
| 188 | + } catch (DbalException $e) { |
| 189 | + // ignore duplicate |
| 190 | + } |
183 | 191 | } else {
|
184 | 192 | // in some cases this is legitimate, like orphaned shares
|
185 | 193 | $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint());
|
|
0 commit comments