Skip to content

Commit

Permalink
fix: remove use of depricated insertIfNotExist from UserMountCache
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Mar 4, 2024
1 parent 76a7a09 commit e61c4a1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/private/Files/Config/UserMountCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
namespace OC\Files\Config;

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

private function addToCache(ICachedMountInfo $mount) {
if ($mount->getStorageId() !== -1) {
$this->connection->insertIfNotExist('*PREFIX*mounts', [
'storage_id' => $mount->getStorageId(),
'root_id' => $mount->getRootId(),
'user_id' => $mount->getUser()->getUID(),
'mount_point' => $mount->getMountPoint(),
'mount_id' => $mount->getMountId(),
'mount_provider_class' => $mount->getMountProvider(),
], ['root_id', 'user_id', 'mount_point']);
$query = $this->connection->getQueryBuilder();
$query->insert('mounts')
->values([
'storage_id' => $query->createNamedParameter($mount->getStorageId(), IQueryBuilder::PARAM_INT),
'root_id' => $query->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT),
'user_id' => $query->createNamedParameter($mount->getUser()->getUID()),
'mount_point' => $query->createNamedParameter($mount->getMountPoint()),
'mount_id' => $query->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT),
'mount_provider_class' => $query->createNamedParameter($mount->getMountProvider()),
]);
try {
$query->executeStatement();
} catch (DbalException $e) {
// ignore duplicate
}
} else {
// in some cases this is legitimate, like orphaned shares
$this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint());
Expand Down

0 comments on commit e61c4a1

Please sign in to comment.