Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable9] Fix default quota #28302

Merged
merged 2 commits into from
Jul 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$userQuota === null won't happen ever I think. Not a big deal anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm indeed, missed that in the original port (might even have been part of the original code I reverted)

return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
return OC_Helper::computerFileSize($userQuota);
Expand Down