Skip to content

Commit 1c37659

Browse files
committed
fix(versions): Catch UniqueConstraintViolationException
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 16141a7 commit 1c37659

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Versions/VersionsBackend.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
declare(strict_types=1);
4+
45
/**
56
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
67
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -431,7 +432,13 @@ public function importVersionsForFile(IUser $user, Node $source, Node $target, a
431432
$versionEntity->setDecodedMetadata($version->getMetadata());
432433
}
433434

434-
$this->groupVersionsMapper->insert($versionEntity);
435+
try {
436+
$this->groupVersionsMapper->insert($versionEntity);
437+
} catch (\OCP\DB\Exception $e) {
438+
if ($e->getReason() !== \OCP\DB\Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
439+
throw $e;
440+
}
441+
}
435442
}
436443
}
437444

0 commit comments

Comments
 (0)