Merge pull request #9300 from owncloud/extstorage-listfilterfix

Use filtered list for ext storage list mounts API
remotes/origin/ldap_group_count
Vincent Petry 12 years ago
commit 19ab6165e7
  1. 31
      apps/files_external/lib/api.php
  2. 5
      apps/files_external/lib/config.php

@ -27,27 +27,32 @@ class Api {
/** /**
* Formats the given mount config to a mount entry. * Formats the given mount config to a mount entry.
* *
* @param bool $isSystemMount true for system mount, false * @param string $mountPoint mount point name, relative to the data dir
* for personal mount * @param array $mountConfig mount config to format
* *
* @return array entry * @return array entry
*/ */
private static function formatMount($mountConfig, $isSystemMount = false) { private static function formatMount($mountPoint, $mountConfig) {
// split user name from mount point // strip "/$user/files" from mount point
$path = dirname($mountConfig['mountpoint']); $mountPoint = explode('/', trim($mountPoint, '/'), 3);
$mountPoint = $mountPoint[2];
// split path from mount point
$path = dirname($mountPoint);
if ($path === '.') { if ($path === '.') {
$path = ''; $path = '';
} }
$isSystemMount = !$mountConfig['personal'];
$permissions = \OCP\PERMISSION_READ; $permissions = \OCP\PERMISSION_READ;
// personal mounts can be deleted // personal mounts can be deleted
if (!$isSystemMount) { if (!$isSystemMount) {
$permissions |= \OCP\PERMISSION_DELETE; $permissions |= \OCP\PERMISSION_DELETE;
} }
// TODO: add storageType, might need to use another OC_Mount_Config method
$entry = array( $entry = array(
'name' => basename($mountConfig['mountpoint']), 'name' => basename($mountPoint),
'path' => $path, 'path' => $path,
'type' => 'dir', 'type' => 'dir',
'backend' => $mountConfig['backend'], 'backend' => $mountConfig['backend'],
@ -67,15 +72,9 @@ class Api {
$entries = array(); $entries = array();
$user = \OC_User::getUser(); $user = \OC_User::getUser();
$personalMounts = \OC_Mount_Config::getPersonalMountPoints(); $mounts = \OC_Mount_Config::getAbsoluteMountPoints($user);
$systemMounts = \OC_Mount_Config::getSystemMountPoints(); foreach($mounts as $mountPoint => $mount) {
$entries[] = self::formatMount($mountPoint, $mount);
foreach ($systemMounts as $mountConfig) {
$entries[] = self::formatMount($mountConfig, true);
}
foreach ($personalMounts as $mountConfig) {
$entries[] = self::formatMount($mountConfig, false);
} }
return new \OC_OCS_Result($entries); return new \OC_OCS_Result($entries);

@ -156,6 +156,7 @@ class OC_Mount_Config {
if ( (!isset($mountPoints[$mountPoint])) if ( (!isset($mountPoints[$mountPoint]))
|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) { || ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
$options['priority_type'] = self::MOUNT_TYPE_GLOBAL; $options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
$options['backend'] = $backends[$options['class']]['backend'];
$mountPoints[$mountPoint] = $options; $mountPoints[$mountPoint] = $options;
} }
} }
@ -177,6 +178,7 @@ class OC_Mount_Config {
if ( (!isset($mountPoints[$mountPoint])) if ( (!isset($mountPoints[$mountPoint]))
|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) { || ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
$options['priority_type'] = self::MOUNT_TYPE_GLOBAL; $options['priority_type'] = self::MOUNT_TYPE_GLOBAL;
$options['backend'] = $backends[$options['class']]['backend'];
$mountPoints[$mountPoint] = $options; $mountPoints[$mountPoint] = $options;
} }
} }
@ -201,6 +203,7 @@ class OC_Mount_Config {
|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
|| ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_GROUP) ) { || ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_GROUP) ) {
$options['priority_type'] = self::MOUNT_TYPE_GROUP; $options['priority_type'] = self::MOUNT_TYPE_GROUP;
$options['backend'] = $backends[$options['class']]['backend'];
$mountPoints[$mountPoint] = $options; $mountPoints[$mountPoint] = $options;
} }
} }
@ -227,6 +230,7 @@ class OC_Mount_Config {
|| ($options['priority'] >= $mountPoints[$mountPoint]['priority']) || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
|| ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_USER) ) { || ($mountPoints[$mountPoint]['priority_type'] !== self::MOUNT_TYPE_USER) ) {
$options['priority_type'] = self::MOUNT_TYPE_USER; $options['priority_type'] = self::MOUNT_TYPE_USER;
$options['backend'] = $backends[$options['class']]['backend'];
$mountPoints[$mountPoint] = $options; $mountPoints[$mountPoint] = $options;
} }
} }
@ -243,6 +247,7 @@ class OC_Mount_Config {
// Always override previous config // Always override previous config
$options['priority_type'] = self::MOUNT_TYPE_PERSONAL; $options['priority_type'] = self::MOUNT_TYPE_PERSONAL;
$options['backend'] = $backends[$options['class']]['backend'];
$mountPoints[$mountPoint] = $options; $mountPoints[$mountPoint] = $options;
} }
} }

Loading…
Cancel
Save