From 8e3f21d9ed74d2ec33a2093a2a577b34d1503c47 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 11 Oct 2022 14:00:15 +0200 Subject: Small progress with fixing unit tests Signed-off-by: Carl Schwan --- apps/files_sharing/lib/Controller/ShareAPIController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 2689cdd79e7..9dc7544644b 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -537,6 +537,7 @@ class ShareAPIController extends OCSController { $share = $this->setShareAttributes($share, $attributes); } + $share->setSharedBy($this->currentUser); $this->checkInheritedAttributes($share); if ($shareType === IShare::TYPE_USER) { @@ -691,7 +692,6 @@ class ShareAPIController extends OCSController { } $share->setShareType($shareType); - $share->setSharedBy($this->currentUser); if ($note !== '') { $share->setNote($note); @@ -1894,10 +1894,13 @@ class ShareAPIController extends OCSController { } private function checkInheritedAttributes(IShare $share): void { + if (!$share->getSharedBy()) { + return; // Probably in a test + } $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); $nodes = $userFolder->getById($share->getNodeId()); if (empty($nodes)) { - throw new NotFoundException('Node for share not found, fileid: ' . $share->getNodeId()); + return; } $node = $nodes[0]; if ($node->getStorage()->instanceOfStorage(SharedStorage::class)) { -- cgit v1.2.3