From 47fd6730e0da7d15d5cd0ef550ce2c957208f8eb Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jan 2020 10:57:54 +0100 Subject: use `nodeExists` instead of catching exceptions makes the intent of the code more clear imo Signed-off-by: Robin Appelman --- lib/private/DirectEditing/Manager.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/private/DirectEditing') 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(); -- cgit v1.2.3