]> source.dussan.org Git - nextcloud-server.git/commitdiff
get node by path as fallback
authorRobin Appelman <robin@icewind.nl>
Wed, 21 Sep 2016 16:55:58 +0000 (18:55 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 12 Oct 2016 14:12:37 +0000 (16:12 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/lib/API/Share20OCS.php

index d5a6d8bc9db3984fe17ee5b6ee69a655fa1c3e8a..ac9ddc1fffa79cce64d0bc81c6c84ed63cd703ee 100644 (file)
@@ -140,10 +140,14 @@ class Share20OCS extends OCSController {
                        $nodes = $userFolder->getById($share->getNodeId());
 
                        if (empty($nodes)) {
-                               throw new NotFoundException();
+                               // fallback to guessing the path
+                               $node = $userFolder->get($share->getTarget());
+                               if ($node === null) {
+                                       throw new NotFoundException();
+                               }
+                       } else {
+                               $node = $nodes[0];
                        }
-
-                       $node = $nodes[0];
                }
 
                $result['path'] = $userFolder->getRelativePath($node->getPath());
@@ -405,8 +409,6 @@ class Share20OCS extends OCSController {
 
                try {
                        $share = $this->shareManager->createShare($share);
-                       $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID());
-                       $recipientNode = $userFolder->get($share->getTarget());
                } catch (GenericShareException $e) {
                        $code = $e->getCode() === 0 ? 403 : $e->getCode();
                        throw new OCSException($e->getHint(), $code);
@@ -416,7 +418,7 @@ class Share20OCS extends OCSController {
                        $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
                }
 
-               $output = $this->formatShare($share, $recipientNode);
+               $output = $this->formatShare($share);
 
                return new DataResponse($output);
        }