diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 7ca1b677fb591..7032e6193850f 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -117,13 +117,15 @@ public function reset() { */ protected function store($mimetype) { try { - $insert = $this->dbConnection->getQueryBuilder(); - $insert->insert('mimetypes') - ->values([ - 'mimetype' => $insert->createNamedParameter($mimetype) - ]) - ->executeStatement(); - $mimetypeId = $insert->getLastInsertId(); + $mimetypeId = $this->atomic(function () use ($mimetype) { + $insert = $this->dbConnection->getQueryBuilder(); + $insert->insert('mimetypes') + ->values([ + 'mimetype' => $insert->createNamedParameter($mimetype) + ]) + ->executeStatement(); + return $insert->getLastInsertId(); + }, $this->dbConnection); } catch (DbalException $e) { if ($e->getReason() !== DBException::REASON_UNIQUE_CONSTRAINT_VIOLATION) { throw $e;