summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-28 17:06:26 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-04-13 12:58:51 +0200
commit3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e (patch)
tree23935b8b8c0df29875cdd1c6d2133bf399a2b724
parent4bcb7d88b5cbb8d2c83176062dc76c6213a13c48 (diff)
downloadnextcloud-server-3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e.tar.gz
nextcloud-server-3c1365c0d12a626e8c2b8e1ab35b105f4b88ad2e.zip
Fix returned paths for remote shares
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php3
-rw-r--r--lib/private/Share20/ShareHelper.php29
-rw-r--r--lib/public/Share/IManager.php2
-rw-r--r--lib/public/Share/IShareHelper.php2
-rw-r--r--lib/public/Share/IShareProvider.php2
5 files changed, 13 insertions, 25 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index bf50206a733..617db4a45ac 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -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'],
];
}
diff --git a/lib/private/Share20/ShareHelper.php b/lib/private/Share20/ShareHelper.php
index b5640d04552..ba3f64dbc1a 100644
--- a/lib/private/Share20/ShareHelper.php
+++ b/lib/private/Share20/ShareHelper.php
@@ -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];
+ }
}
diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php
index 1cbb27cb618..5f02e1d9804 100644
--- a/lib/public/Share/IManager.php
+++ b/lib/public/Share/IManager.php
@@ -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
* ]
diff --git a/lib/public/Share/IShareHelper.php b/lib/public/Share/IShareHelper.php
index 01202cf477b..4ec62830c52 100644
--- a/lib/public/Share/IShareHelper.php
+++ b/lib/public/Share/IShareHelper.php
@@ -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);
diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php
index fba432f31e7..bac1a5d87f0 100644
--- a/lib/public/Share/IShareProvider.php
+++ b/lib/public/Share/IShareProvider.php
@@ -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
* ]