aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DirectEditing
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-01-14 10:57:54 +0100
committerRobin Appelman <robin@icewind.nl>2020-01-14 11:03:14 +0100
commit47fd6730e0da7d15d5cd0ef550ce2c957208f8eb (patch)
tree1be46e13b78f7391c07fdf5792ab8aa85c751181 /lib/private/DirectEditing
parent950856d5bbd46e6d4a608c46c40631487f13c5e0 (diff)
downloadnextcloud-server-47fd6730e0da7d15d5cd0ef550ce2c957208f8eb.tar.gz
nextcloud-server-47fd6730e0da7d15d5cd0ef550ce2c957208f8eb.zip
use `nodeExists` instead of catching exceptions
makes the intent of the code more clear imo Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/DirectEditing')
-rw-r--r--lib/private/DirectEditing/Manager.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php
index ac85e62cb72..5e3f7755938 100644
--- a/lib/private/DirectEditing/Manager.php
+++ b/lib/private/DirectEditing/Manager.php
@@ -124,10 +124,9 @@ class Manager implements IManager {
public function create(string $path, string $editorId, string $creatorId, $templateId = null): string {
$userFolder = $this->rootFolder->getUserFolder($this->userId);
- try {
- $file = $userFolder->get($path);
+ if ($userFolder->nodeExists($path)) {
throw new \RuntimeException('File already exists');
- } catch (\OCP\Files\NotFoundException $e) {
+ } else {
$file = $userFolder->newFile($path);
$editor = $this->getEditor($editorId);
$creators = $editor->getCreators();