[Pkg-owncloud-commits] [owncloud] 132/273: Use filtered list for ext storage list mounts API

David Prévot taffit at moszumanska.debian.org
Fri Jul 4 03:13:09 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 8977a68548aef5728cd36a0959fb3a938741c505
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon Jun 30 12:33:11 2014 +0200

    Use filtered list for ext storage list mounts API
    
    Now the external storage correctly returns the mount points visible only
    for the current user by using the method getAbsoluteMountPoints() which
    is already filtered.
    
    Since that call was missing the backend name which is important for the
    UI, this one was added as well.
---
 apps/files_external/lib/api.php    | 31 +++++++++++++++----------------
 apps/files_external/lib/config.php |  5 +++++
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php
index 51c4842..81ebd4e 100644
--- a/apps/files_external/lib/api.php
+++ b/apps/files_external/lib/api.php
@@ -27,27 +27,32 @@ class Api {
 	/**
 	 * Formats the given mount config to a mount entry.
 	 * 
-	 * @param bool $isSystemMount true for system mount, false
-	 * for personal mount
+	 * @param string $mountPoint mount point name, relative to the data dir
+	 * @param array $mountConfig mount config to format
 	 *
 	 * @return array entry
 	 */
-	private static function formatMount($mountConfig, $isSystemMount = false) {
-		// split user name from mount point
-		$path = dirname($mountConfig['mountpoint']);
+	private static function formatMount($mountPoint, $mountConfig) {
+		// strip "/$user/files" from mount point
+		$mountPoint = explode('/', trim($mountPoint, '/'), 3);
+		$mountPoint = $mountPoint[2];
+
+		// split path from mount point
+		$path = dirname($mountPoint);
 		if ($path === '.') {
 			$path = '';
 		}
 
+		$isSystemMount = !$mountConfig['personal'];
+
 		$permissions = \OCP\PERMISSION_READ;
 		// personal mounts can be deleted
 		if (!$isSystemMount) {
 			$permissions |= \OCP\PERMISSION_DELETE;
 		}
 
-		// TODO: add storageType, might need to use another OC_Mount_Config method
 		$entry = array(
-			'name' => basename($mountConfig['mountpoint']),
+			'name' => basename($mountPoint),
 			'path' => $path,
 			'type' => 'dir',
 			'backend' => $mountConfig['backend'],
@@ -67,15 +72,9 @@ class Api {
 		$entries = array();
 		$user = \OC_User::getUser();
 
-		$personalMounts = \OC_Mount_Config::getPersonalMountPoints();
-		$systemMounts = \OC_Mount_Config::getSystemMountPoints();
-
-		foreach ($systemMounts as $mountConfig) {
-			$entries[] = self::formatMount($mountConfig, true);
-		}
-
-		foreach ($personalMounts as $mountConfig) {
-			$entries[] = self::formatMount($mountConfig, false);
+		$mounts = \OC_Mount_Config::getAbsoluteMountPoints($user);
+		foreach($mounts as $mountPoint => $mount) {
+			$entries[] = self::formatMount($mountPoint, $mount);
 		}
 
 		return new \OC_OCS_Result($entries);
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index ec908fb..f860d5e 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -156,6 +156,7 @@ class OC_Mount_Config {
 				if ( (!isset($mountPoints[$mountPoint]))
 					|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
 					$options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
+					$options['backend'] = $backends[$options['class']]['backend'];
 					$mountPoints[$mountPoint] = $options;
 				}
 			}
@@ -177,6 +178,7 @@ class OC_Mount_Config {
 				if ( (!isset($mountPoints[$mountPoint]))
 					|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
 					$options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
+					$options['backend'] = $backends[$options['class']]['backend'];
 					$mountPoints[$mountPoint] = $options;
 				}
 			}
@@ -201,6 +203,7 @@ class OC_Mount_Config {
 							|| ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
 							|| ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_GROUP) ) {
 							$options['priority_type'] = self::MOUNT_TYPE_GROUP;
+							$options['backend'] = $backends[$options['class']]['backend'];
 							$mountPoints[$mountPoint] = $options;
 						}
 					}
@@ -227,6 +230,7 @@ class OC_Mount_Config {
 							|| ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
 							|| ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_USER) ) {
 							$options['priority_type'] = self::MOUNT_TYPE_USER;
+							$options['backend'] = $backends[$options['class']]['backend'];
 							$mountPoints[$mountPoint] = $options;
 						}
 					}
@@ -243,6 +247,7 @@ class OC_Mount_Config {
 
 				// Always override previous config
 				$options['priority_type'] = self::MOUNT_TYPE_PERSONAL;
+				$options['backend'] = $backends[$options['class']]['backend'];
 				$mountPoints[$mountPoint] = $options;
 			}
 		}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list