|
21 | 21 | use OCP\Share\IAttributes; |
22 | 22 | use OCP\Share\IManager; |
23 | 23 | use OCP\Share\IShare; |
| 24 | +use OCP\User\Exceptions\UserNotFoundException; |
24 | 25 | use Override; |
25 | 26 |
|
26 | 27 | class Share implements IShare { |
@@ -135,20 +136,24 @@ public function getNode(): Node { |
135 | 136 | throw new NotFoundException(); |
136 | 137 | } |
137 | 138 |
|
138 | | - // for federated shares the owner can be a remote user, in this |
139 | | - // case we use the initiator |
140 | | - if ($this->userManager->userExists($this->shareOwner)) { |
141 | | - $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); |
142 | | - } else { |
143 | | - $userFolder = $this->rootFolder->getUserFolder($this->sharedBy); |
144 | | - } |
145 | | - |
146 | | - $node = $userFolder->getFirstNodeById($this->fileId); |
147 | | - if (!$node) { |
148 | | - throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); |
| 139 | + try { |
| 140 | + // for federated shares the owner can be a remote user, in this |
| 141 | + // case we use the initiator |
| 142 | + if ($this->userManager->userExists($this->shareOwner)) { |
| 143 | + $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); |
| 144 | + } else { |
| 145 | + $userFolder = $this->rootFolder->getUserFolder($this->sharedBy); |
| 146 | + } |
| 147 | + |
| 148 | + $node = $userFolder->getFirstNodeById($this->fileId); |
| 149 | + if (!$node) { |
| 150 | + throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); |
| 151 | + } |
| 152 | + |
| 153 | + $this->node = $node; |
| 154 | + } catch (UserNotFoundException $e) { |
| 155 | + throw new NotFoundException('Owner for share not found, fileid: ' . $this->fileId, previous:$e); |
149 | 156 | } |
150 | | - |
151 | | - $this->node = $node; |
152 | 157 | } |
153 | 158 |
|
154 | 159 | return $this->node; |
|
0 commit comments