Skip to content

Commit

Permalink
Merge pull request #28302 from owncloud/stable9-fixdefaultquota
Browse files Browse the repository at this point in the history
[stable9] Fix default quota
  • Loading branch information
Vincent Petry authored Jul 5, 2017
2 parents 00a7d23 + 4247bff commit 9b38c9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/files_trashbin/lib/trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ private static function calculateFreeSpace($trashbinSize, $user) {
if(is_null($userObject)) {
return 0;
}
$quota = $userObject->getQuota();
if ($quota === null || $quota === 'none') {
$quota = \OC_Util::getUserQuota($userObject);
if ($quota === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
$quota = Filesystem::free_space('/');
$softQuota = false;
// inf or unknown free space
Expand Down
4 changes: 2 additions & 2 deletions apps/files_versions/lib/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ public static function expire($filename, $uid) {
$versionsFileview = new View('/'.$uid.'/files_versions');

$softQuota = true;
$quota = $user->getQuota();
if ( $quota === null || $quota === 'none' ) {
$quota = \OC_Util::getUserQuota($user);
if ($quota === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
$quota = Filesystem::free_space('/');
$softQuota = false;
} else {
Expand Down
6 changes: 1 addition & 5 deletions lib/private/user/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,7 @@ public function getEMailAddress() {
* @since 9.0.0
*/
public function getQuota() {
$quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
if($quota === 'default') {
$quota = $this->config->getAppValue('files', 'default_quota', 'none');
}
return $quota;
return $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
}

/**
Expand Down
13 changes: 10 additions & 3 deletions lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,23 @@ public static function isDefaultExpireDateEnforced() {
/**
* Get the quota of a user
*
* @param string $userId
* @param string|IUser $userId
* @return int Quota bytes
*/
public static function getUserQuota($userId) {
$user = \OC::$server->getUserManager()->get($userId);
if ($userId instanceof IUser) {
$user = $userId;
} else {
$user = \OC::$server->getUserManager()->get($userId);
}
if (is_null($user)) {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
$userQuota = $user->getQuota();
if($userQuota === 'none') {
if ($userQuota === null || $userQuota === 'default') {
$userQuota = \OC::$server->getConfig()->getAppValue('files', 'default_quota', 'none');
}
if ($userQuota === null || $userQuota === 'none') {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
return OC_Helper::computerFileSize($userQuota);
Expand Down

0 comments on commit 9b38c9d

Please sign in to comment.