|
9 | 9 |
|
10 | 10 | use OC\User\LazyUser; |
11 | 11 | use OCP\Cache\CappedMemoryCache; |
12 | | -use OCP\DB\Exception; |
13 | 12 | use OCP\DB\QueryBuilder\IQueryBuilder; |
14 | 13 | use OCP\Diagnostics\IEventLogger; |
15 | 14 | use OCP\EventDispatcher\IEventDispatcher; |
@@ -165,25 +164,15 @@ private function findChangedMounts(array $newMounts, array $cachedMounts): array |
165 | 164 |
|
166 | 165 | private function addToCache(ICachedMountInfo $mount) { |
167 | 166 | if ($mount->getStorageId() !== -1) { |
168 | | - $qb = $this->connection->getQueryBuilder(); |
169 | | - $qb |
170 | | - ->insert('mounts') |
171 | | - ->values([ |
172 | | - 'storage_id' => $qb->createNamedParameter($mount->getStorageId(), IQueryBuilder::PARAM_INT), |
173 | | - 'root_id' => $qb->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT), |
174 | | - 'user_id' => $qb->createNamedParameter($mount->getUser()->getUID()), |
175 | | - 'mount_point' => $qb->createNamedParameter($mount->getMountPoint()), |
176 | | - 'mount_point_hash' => $qb->createNamedParameter(hash('xxh128', $mount->getMountPoint())), |
177 | | - 'mount_id' => $qb->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT), |
178 | | - 'mount_provider_class' => $qb->createNamedParameter($mount->getMountProvider()), |
179 | | - ]); |
180 | | - try { |
181 | | - $qb->executeStatement(); |
182 | | - } catch (Exception $e) { |
183 | | - if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) { |
184 | | - throw $e; |
185 | | - } |
186 | | - } |
| 167 | + $this->connection->insertIgnoreConflict('mounts', [ |
| 168 | + 'storage_id' => $mount->getStorageId(), |
| 169 | + 'root_id' => $mount->getRootId(), |
| 170 | + 'user_id' => $mount->getUser()->getUID(), |
| 171 | + 'mount_point' => $mount->getMountPoint(), |
| 172 | + 'mount_point_hash' => hash('xxh128', $mount->getMountPoint()), |
| 173 | + 'mount_id' => $mount->getMountId(), |
| 174 | + 'mount_provider_class' => $mount->getMountProvider(), |
| 175 | + ]); |
187 | 176 | } else { |
188 | 177 | // in some cases this is legitimate, like orphaned shares |
189 | 178 | $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); |
|
0 commit comments