diff options
-rw-r--r-- | lib/private/Lock/DBLockingProvider.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index 6adb7488217..79f2ff274cf 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -26,6 +26,7 @@ namespace OC\Lock; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use OC\DB\QueryBuilder\Literal; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -133,7 +134,17 @@ class DBLockingProvider extends AbstractLockingProvider { protected function initLockField(string $path, int $lock = 0): int { $expire = $this->getExpireTime(); - return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']); + + try { + $builder = $this->connection->getQueryBuilder(); + return $builder->insert('file_locks') + ->setValue('key', $builder->createNamedParameter($path)) + ->setValue('lock', $builder->createNamedParameter($lock)) + ->setValue('ttl', $builder->createNamedParameter($expire)) + ->execute(); + } catch(UniqueConstraintViolationException $e) { + return 0; + } } /** |