Commit 55fa1d4a authored by Pål Karlsrud's avatar Pål Karlsrud

If a subfolder is specified and does not exist, create it.

parent 7872d8fd
......@@ -63,7 +63,17 @@ class GroupHooks {
$storage->setBackend(\OC::$server->query('StoragesBackendService')->getBackend("local"));
$base_data_dir = \OC::$server->getConfig()->getSystemValue('base_data_dir', "/data");
$data_subfolder = \OC::$server->getConfig()->getSystemValue('data_subfolder', "shared");
$storage->setBackendOptions(["datadir" => join('/', array($base_data_dir, $group_mas_id, $data_subfolder))]);
$group_folder_path = join('/', array($base_data_dir, $group_mas_id));
// Ensure that the subfolder actually exists, but only if the parent folder already exists.
$group_folder = new \OC\Files\Storage\Local(['datadir' => $group_folder_path]);
if ($group_folder->is_dir("") && !$group_folder->is_dir($data_subfolder)) {
\OCP\Util::writeLog('remote', "Created subfolder '$data_subfolder' in '$group_folder_path'", \OCP\Util::DEBUG);
$group_folder->mkdir($data_subfolder);
}
$storage->setBackendOptions(["datadir" => join('/', array($group_folder_path, $data_subfolder))]);
$storageService->addStorage($storage);
};
$this->groupManager->listen('\OC\Group', 'postCreate', $callback);
......
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