Ignore UniqueConstraintViolationException when creating new items.

This commit is contained in:
Joachim Bauch 2021-11-10 11:48:09 +01:00
parent 7d542eb3d0
commit 27abab0dee
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace OCA\Pdfdraw\Controller;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use \Firebase\JWT\JWT;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDownloadResponse;
@ -174,7 +175,11 @@ class ApiController extends OCSController {
'data' => $query->createNamedParameter($data),
]
);
$query->execute();
try {
$query->execute();
} catch (UniqueConstraintViolationException $e) {
// Ignore, another request created the item.
}
}
return new DataResponse([]);
}