Catch NotFoundException and return no quota information which simply reflects the current state - no file storage has been initialized for the user.
This commit is contained in:
parent
ad88a7d53d
commit
6d97dfb00c
|
@ -27,6 +27,7 @@ use \OC_SubAdmin;
|
||||||
use \OC_User;
|
use \OC_User;
|
||||||
use \OC_Group;
|
use \OC_Group;
|
||||||
use \OC_Helper;
|
use \OC_Helper;
|
||||||
|
use OCP\Files\NotFoundException;
|
||||||
|
|
||||||
class Users {
|
class Users {
|
||||||
|
|
||||||
|
@ -92,16 +93,8 @@ class Users {
|
||||||
$config = \OC::$server->getConfig();
|
$config = \OC::$server->getConfig();
|
||||||
|
|
||||||
// Find the data
|
// Find the data
|
||||||
$data = array();
|
$data = [];
|
||||||
\OC_Util::tearDownFS();
|
$data = self::fillStorageInfo($userId, $data);
|
||||||
\OC_Util::setupFS($userId);
|
|
||||||
$storage = OC_Helper::getStorageInfo('/');
|
|
||||||
$data['quota'] = array(
|
|
||||||
'free' => $storage['free'],
|
|
||||||
'used' => $storage['used'],
|
|
||||||
'total' => $storage['total'],
|
|
||||||
'relative' => $storage['relative'],
|
|
||||||
);
|
|
||||||
$data['enabled'] = $config->getUserValue($userId, 'core', 'enabled', 'true');
|
$data['enabled'] = $config->getUserValue($userId, 'core', 'enabled', 'true');
|
||||||
$data['email'] = $config->getUserValue($userId, 'settings', 'email');
|
$data['email'] = $config->getUserValue($userId, 'settings', 'email');
|
||||||
$data['displayname'] = OC_User::getDisplayName($parameters['userid']);
|
$data['displayname'] = OC_User::getDisplayName($parameters['userid']);
|
||||||
|
@ -350,4 +343,27 @@ class Users {
|
||||||
return new OC_OCS_Result($groups);
|
return new OC_OCS_Result($groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userId
|
||||||
|
* @param $data
|
||||||
|
* @return mixed
|
||||||
|
* @throws \OCP\Files\NotFoundException
|
||||||
|
*/
|
||||||
|
private static function fillStorageInfo($userId, $data) {
|
||||||
|
try {
|
||||||
|
\OC_Util::tearDownFS();
|
||||||
|
\OC_Util::setupFS($userId);
|
||||||
|
$storage = OC_Helper::getStorageInfo('/');
|
||||||
|
$data['quota'] = [
|
||||||
|
'free' => $storage['free'],
|
||||||
|
'used' => $storage['used'],
|
||||||
|
'total' => $storage['total'],
|
||||||
|
'relative' => $storage['relative'],
|
||||||
|
];
|
||||||
|
} catch (NotFoundException $ex) {
|
||||||
|
$data['quota'] = [];
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue