aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/config.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/config.php')
-rwxr-xr-xapps/files_external/lib/config.php37
1 files changed, 30 insertions, 7 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index d78c69e83db..2f3dbf10691 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -143,7 +143,9 @@ class OC_Mount_Config {
'class' => $mount['class'],
'backend' => $backends[$mount['class']]['backend'],
'configuration' => $mount['options'],
- 'applicable' => array('groups' => array($group), 'users' => array()));
+ 'applicable' => array('groups' => array($group), 'users' => array()),
+ 'status' => self::getBackendStatus($mount['class'], $mount['options'])
+ );
}
}
}
@@ -162,10 +164,13 @@ class OC_Mount_Config {
$system[$mountPoint]['applicable']['users']
= array_merge($system[$mountPoint]['applicable']['users'], array($user));
} else {
- $system[$mountPoint] = array('class' => $mount['class'],
+ $system[$mountPoint] = array(
+ 'class' => $mount['class'],
'backend' => $backends[$mount['class']]['backend'],
'configuration' => $mount['options'],
- 'applicable' => array('groups' => array(), 'users' => array($user)));
+ 'applicable' => array('groups' => array(), 'users' => array($user)),
+ 'status' => self::getBackendStatus($mount['class'], $mount['options'])
+ );
}
}
}
@@ -190,14 +195,32 @@ class OC_Mount_Config {
$mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
}
// Remove '/uid/files/' from mount point
- $personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'],
- 'backend' => $backends[$mount['class']]['backend'],
- 'configuration' => $mount['options']);
+ $personal[substr($mountPoint, strlen($uid) + 8)] = array(
+ 'class' => $mount['class'],
+ 'backend' => $backends[$mount['class']]['backend'],
+ 'configuration' => $mount['options'],
+ 'status' => self::getBackendStatus($mount['class'], $mount['options'])
+ );
}
}
return $personal;
}
+ private static function getBackendStatus($class, $options) {
+ foreach ($options as &$option) {
+ $option = str_replace('$user', OCP\User::getUser(), $option);
+ }
+ if (class_exists($class)) {
+ try {
+ $storage = new $class($options);
+ return $storage->test();
+ } catch (Exception $exception) {
+ return false;
+ }
+ }
+ return false;
+ }
+
/**
* Add a mount point to the filesystem
* @param string Mount point
@@ -238,7 +261,7 @@ class OC_Mount_Config {
$mountPoints[$mountType] = $mount;
}
self::writeData($isPersonal, $mountPoints);
- return true;
+ return self::getBackendStatus($class, $classOptions);
}
/**