|
31 | 31 | use OCP\AppFramework\OCS\OCSNotFoundException; |
32 | 32 | use OCP\AppFramework\OCSController; |
33 | 33 | use OCP\Files\IRootFolder; |
| 34 | +use OCP\Files\NotFoundException; |
34 | 35 | use OCP\IGroup; |
35 | 36 | use OCP\IGroupManager; |
36 | 37 | use OCP\IRequest; |
@@ -274,12 +275,7 @@ public function updateShare(int $formId, int $shareId, array $keyValuePairs): Da |
274 | 275 | if (in_array(Constants::PERMISSION_RESULTS, $keyValuePairs['permissions'], true)) { |
275 | 276 | $userFolder = $this->rootFolder->getUserFolder($form->getOwnerId()); |
276 | 277 | $uploadedFilesFolderPath = $this->formsService->getFormUploadedFilesFolderPath($form); |
277 | | - if ($userFolder->nodeExists($uploadedFilesFolderPath)) { |
278 | | - $folder = $userFolder->get($uploadedFilesFolderPath); |
279 | | - } else { |
280 | | - $folder = $userFolder->newFolder($uploadedFilesFolderPath); |
281 | | - } |
282 | | - /** @var \OCP\Files\Folder $folder */ |
| 278 | + $folder = $userFolder->getOrCreateFolder($uploadedFilesFolderPath); |
283 | 279 |
|
284 | 280 | $folderShare = $this->shareManager->newShare(); |
285 | 281 | $folderShare->setShareType($formShare->getShareType()); |
@@ -359,11 +355,11 @@ private function removeUploadedFilesShare(Form $form, Share $formShare): void { |
359 | 355 |
|
360 | 356 | $userFolder = $this->rootFolder->getUserFolder($form->getOwnerId()); |
361 | 357 | $uploadedFilesFolderPath = $this->formsService->getFormUploadedFilesFolderPath($form); |
362 | | - if (!$userFolder->nodeExists($uploadedFilesFolderPath)) { |
| 358 | + try { |
| 359 | + $folder = $userFolder->get($uploadedFilesFolderPath); |
| 360 | + } catch (NotFoundException $e) { |
363 | 361 | return; |
364 | 362 | } |
365 | | - |
366 | | - $folder = $userFolder->get($uploadedFilesFolderPath); |
367 | 363 | $folderShares = $this->shareManager->getSharesBy($form->getOwnerId(), $formShare->getShareType(), $folder, false, -1); |
368 | 364 | foreach ($folderShares as $folderShare) { |
369 | 365 | if ($folderShare->getSharedWith() === $formShare->getShareWith()) { |
|
0 commit comments