Commit a61c2ec7 authored by Pål Karlsrud's avatar Pål Karlsrud

Make the directory used as the base dir when locating group folders

easier to change.
parent de993c75
......@@ -44,9 +44,9 @@ class GroupHooks {
$group_mas_id = substr($group_gid, self::MAS_PREFIX_LEN);
$storageService = \OC::$server->query('GlobalStoragesService');
$storage_id = $group_gid . "-mount";
// Don'ẗ modify the storage if it already exists.
$storage_id = $group_gid . "-mount";
try {
if ($storageService->getStorage($storage_id)) return;
} catch (NotFoundException $e) {
......@@ -54,13 +54,15 @@ class GroupHooks {
$storage = new StorageConfig();
$storage->setId($storage_id);
$storage->setMountPoint($group_mas_id);
$storage->setMountOptions(["enable_sharing" => true]);
$storage->setMountPoint($group_mas_id); // Confusingly, this is just the name of the mount.
$storage->setAuthMechanism(new NullMechanism());
$storage->setBackend(\OC::$server->query('StoragesBackendService')->getBackend("local"));
$storage->setApplicableGroups([$group_gid]);
$storage->setBackendOptions(["datadir" => "/data/" . $group_mas_id]);
$storage->setMountOptions(["enable_sharing" => true]);
$storage->setBackend(\OC::$server->query('StoragesBackendService')->getBackend("local"));
$base_data_dir = \OC::$server->getConfig()->getSystemValue('base_data_dir', "/data");
$storage->setBackendOptions(["datadir" => join('/', array($base_data_dir, $group_mas_id))]);
$storageService->addStorage($storage);
};
$this->groupManager->listen('\OC\Group', 'postCreate', $callback);
......
......@@ -25,7 +25,7 @@ class UserHooks {
$callback = function($user) {
$groups = $this->fetchGroups($this->session->get('oauth_access_token'));
// If a group the user is part of does not exist, create it,
// otherwise add them to the list of members.
// otherwise register them as members.
foreach ($groups as $group) {
$oc_group = $this->groupManager->get($group->id);
......@@ -57,7 +57,7 @@ class UserHooks {
private function fetchGroups($accesstoken) {
//return $this->fetchJsonAPI($accesstoken, "https://daas-mas.dataporten-api.no/groups/me/groups");
return json_decode('[{"gid": 42, "displayName": "bare en test", "id": "fc:mas:halla"}]');
return json_decode('[{"gid": 42, "displayName": "bare en test", "id": "fc:mas:hallaa"}]');
}
private function logout() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment