Merge pull request #910 from nextcloud/stable10_864
[Stable10] Ensure the user exists before calling a method on it
This commit is contained in:
commit
1927c28b9f
|
@ -165,6 +165,7 @@ class OC_Util {
|
|||
|
||||
// install storage availability wrapper, before most other wrappers
|
||||
\OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, $storage) {
|
||||
/** @var \OCP\Files\Storage $storage */
|
||||
if (!$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) {
|
||||
return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]);
|
||||
}
|
||||
|
@ -290,16 +291,19 @@ class OC_Util {
|
|||
/**
|
||||
* Get the quota of a user
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $userId
|
||||
* @return int Quota bytes
|
||||
*/
|
||||
public static function getUserQuota($user) {
|
||||
$userQuota = \OC::$server->getUserManager()->get($user)->getQuota();
|
||||
public static function getUserQuota($userId) {
|
||||
$user = \OC::$server->getUserManager()->get($userId);
|
||||
if (is_null($user)) {
|
||||
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||
}
|
||||
$userQuota = $user->getQuota();
|
||||
if($userQuota === 'none') {
|
||||
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||
}else{
|
||||
return OC_Helper::computerFileSize($userQuota);
|
||||
}
|
||||
return OC_Helper::computerFileSize($userQuota);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue