mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
Merge 6ea4a97634 into d09b8c99de
This commit is contained in:
commit
cbe1f783fc
1 changed files with 11 additions and 3 deletions
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
namespace OC\Files\Cache;
|
||||
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\IDBConnection;
|
||||
|
|
@ -56,9 +57,16 @@ class Storage {
|
|||
$this->numericId = (int)$row['numeric_id'];
|
||||
} else {
|
||||
$available = $isAvailable ? 1 : 0;
|
||||
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
|
||||
$this->numericId = $connection->lastInsertId('*PREFIX*storages');
|
||||
} else {
|
||||
$query = $connection->getQueryBuilder();
|
||||
$query->insert('storages')
|
||||
->values([
|
||||
'id' => $query->createNamedParameter($this->storageId),
|
||||
'available' => $query->createNamedParameter($available, IQueryBuilder::PARAM_INT),
|
||||
]);
|
||||
try {
|
||||
$query->executeStatement();
|
||||
$this->numericId = $query->getLastInsertId();
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
if ($row = self::getStorageById($this->storageId)) {
|
||||
$this->numericId = (int)$row['numeric_id'];
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue