aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DB/Adapter.php13
-rw-r--r--lib/private/DB/Connection.php4
-rw-r--r--lib/private/Lock/DBLockingProvider.php12
3 files changed, 18 insertions, 11 deletions
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php
index b9a5f272c57..139b7828596 100644
--- a/lib/private/DB/Adapter.php
+++ b/lib/private/DB/Adapter.php
@@ -126,4 +126,17 @@ class Adapter {
return 0;
}
}
+
+ public function insertIgnoreConflict($table, $input) : int {
+ try {
+ $builder = $this->conn->getQueryBuilder();
+ $builder->insert($table);
+ foreach($input as $key => $value) {
+ $builder->setValue($key, $builder->createNamedParameter($value));
+ }
+ return $builder->execute();
+ } catch(UniqueConstraintViolationException $e) {
+ return 0;
+ }
+ }
}
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index c63ef0067c1..12a0af6121e 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -257,6 +257,10 @@ class Connection extends ReconnectWrapper implements IDBConnection {
return $this->adapter->insertIfNotExist($table, $input, $compare);
}
+ public function insertIgnoreConflict($table, $input) : int {
+ return $this->adapter->insertIgnoreConflict($table, $input);
+ }
+
private function getType($value) {
if (is_bool($value)) {
return IQueryBuilder::PARAM_BOOL;
diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php
index 6d9c8f1b3d1..a1859047fe6 100644
--- a/lib/private/Lock/DBLockingProvider.php
+++ b/lib/private/Lock/DBLockingProvider.php
@@ -134,17 +134,7 @@ class DBLockingProvider extends AbstractLockingProvider {
protected function initLockField(string $path, int $lock = 0): int {
$expire = $this->getExpireTime();
-
- 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;
- }
+ return $this->connection->insertIgnoreConflict('file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire]);
}
/**