]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix returned paths for remote shares
authorJoas Schilling <coding@schilljs.com>
Tue, 28 Mar 2017 15:06:26 +0000 (17:06 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 13 Apr 2017 10:58:51 +0000 (12:58 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/federatedfilesharing/lib/FederatedShareProvider.php
lib/private/Share20/ShareHelper.php
lib/public/Share/IManager.php
lib/public/Share/IShareHelper.php
lib/public/Share/IShareProvider.php

index bf50206a733e18517b78e50fd108eeec0041255d..617db4a45ac5c73fc307e7119a6cd4fb6c3c7d8c 100644 (file)
@@ -983,7 +983,7 @@ class FederatedShareProvider implements IShareProvider {
                }
 
                $qb = $this->dbConnection->getQueryBuilder();
-               $qb->select('share_with', 'token', 'file_source', 'file_target')
+               $qb->select('share_with', 'token', 'file_source')
                        ->from('share')
                        ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
                        ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
@@ -997,7 +997,6 @@ class FederatedShareProvider implements IShareProvider {
                while ($row = $cursor->fetch()) {
                        $remote[$row['share_with']] = [
                                'node_id' => $row['file_source'],
-                               'node_path' => $row['file_target'],
                                'token' => $row['token'],
                        ];
                }
index b5640d045526afa8e1d1e425a22ae2cd135ec9d6..ba3f64dbc1a90907c787c41af45bddd5acc8c3e5 100644 (file)
@@ -37,7 +37,7 @@ class ShareHelper implements IShareHelper {
 
        /**
         * @param Node $node
-        * @return array [ users => [Mapping $uid => $path], remotes => [Mapping $cloudId => $path]]
+        * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
         */
        public function getPathsForAccessList(Node $node) {
                $result = [
@@ -103,26 +103,10 @@ class ShareHelper implements IShareHelper {
                        $byId[$info['node_id']][$cloudId] = $info['token'];
                }
 
-               if (isset($byId[$node->getId()])) {
-                       foreach ($byId[$node->getId()] as $cloudId => $token) {
-                               $results[$cloudId] = [
-                                       'node_path' => '/' . $node->getName(),
-                                       'token' => $token,
-                               ];
-                       }
-                       unset($byId[$node->getId()]);
-               }
-
-               if (empty($byId)) {
-                       return $results;
-               }
-
                $item = $node;
-               $path = '/' . $node->getName();
                while (!empty($byId)) {
-                       $item = $item->getParent();
-
                        if (!empty($byId[$item->getId()])) {
+                               $path = $this->getMountedPath($item);
                                foreach ($byId[$item->getId()] as $uid => $token) {
                                        $results[$uid] = [
                                                'node_path' => $path,
@@ -131,10 +115,15 @@ class ShareHelper implements IShareHelper {
                                }
                                unset($byId[$item->getId()]);
                        }
-
-                       $path = '/' . $item->getName() . $path;
+                       $item = $item->getParent();
                }
 
                return $results;
        }
+
+       protected function getMountedPath(Node $node) {
+               $path = $node->getPath();
+               $sections = explode('/', $path, 4);
+               return '/' . $sections[3];
+       }
 }
index 1cbb27cb618688fd68a419e8fa5e0106fd1f3422..5f02e1d9804468c066d1ab3870bd42a716b3ade3 100644 (file)
@@ -208,7 +208,7 @@ interface IManager {
         * Then the access list will to '/folder1/folder2/fileA' is:
         * [
         *  users  => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
-        *  remote => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
+        *  remote => ['user1' => ['node_id' => 42, 'token' => 'ShareToken'], 'user2' => [...]],
         *  public => bool
         *  mail => bool
         * ]
index 01202cf477bbe611108a7dba43268c59d0a35462..4ec62830c52d4a9a917d0622bfa6cf000a5fa823 100644 (file)
@@ -34,7 +34,7 @@ interface IShareHelper {
 
        /**
         * @param Node $node
-        * @return array [ users => [Mapping $uid => $path], remotes => [Mapping $cloudId => $path]]
+        * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
         * @since 12
         */
        public function getPathsForAccessList(Node $node);
index fba432f31e7d7835a0c736577647784eee9f83b0..bac1a5d87f01927cf7700d41abdf61abc04b1e30 100644 (file)
@@ -197,7 +197,7 @@ interface IShareProvider {
         *
         * [
         *  users  => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
-        *  remote => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
+        *  remote => ['user1' => ['node_id' => 42, 'token' => 'ShareToken'], 'user2' => [...]],
         *  mail   => bool
         *  public => bool
         * ]