Skip to content

Commit e61c4a1

Browse files
committed
fix: remove use of depricated insertIfNotExist from UserMountCache
Signed-off-by: Robin Appelman <[email protected]>
1 parent 76a7a09 commit e61c4a1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/private/Files/Config/UserMountCache.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
namespace OC\Files\Config;
3030

31+
use OC\DB\Exceptions\DbalException;
3132
use OCP\Cache\CappedMemoryCache;
3233
use OCP\DB\QueryBuilder\IQueryBuilder;
3334
use OCP\Diagnostics\IEventLogger;
@@ -172,14 +173,21 @@ private function findChangedMounts(array $newMounts, array $cachedMounts) {
172173

173174
private function addToCache(ICachedMountInfo $mount) {
174175
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+
}
183191
} else {
184192
// in some cases this is legitimate, like orphaned shares
185193
$this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint());

0 commit comments

Comments
 (0)