Skip to content

Proper separation of quota values in APIs - #27895

Merged
PVince81 merged 3 commits into
masterfrom
fixdefaultquota
May 16, 2017
Merged

PVince81 merged 3 commits into
masterfrom
fixdefaultquota

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Description

User::getQuota() and User::setQuota() are now reading the exact value as
set in the database instead of interpreting it. This is how it used to
behave.

Util::getUserQuota() is the method that interprets the quota for example
by replacing a default value with the default quota value from the app
config.

Basically the users page must show exactly what's stored in the DB and not interpret the values.

@DeepDiver1975 also fixes misinterpretation of default which should be "default", not "none" in account table.

Related Issue

Fixes #27803

Motivation and Context

Bring back correct default quota behavior.

How Has This Been Tested?

See steps in ticket.
Set one user to "Unlimited" in users page.
Set one user to "Default" in users page.
Set default quota to "1 GB".
Refresh page.

Before fix: quota appears as "1 GB" instead of selected values.
After fix: quota appears as whatever was selected before which is what is stored in DB.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Some unit tests may fail, we'll see.

@jvillafanez can you check whether this could influence LDAP default quota handling ?

@davitol

@DeepDiver1975

Copy link
Copy Markdown
Contributor

bildschirmfoto von 2017-05-16 08-44-14

@jvillafanez

Copy link
Copy Markdown
Member

@jvillafanez can you check whether this could influence LDAP default quota handling ?

From 9.1.5 onwards, LDAP can accept "none" and "default" as quota values. Those exact values will be written as quota for the user. There is no further action over those values from the LDAP app.

@PVince81

Copy link
Copy Markdown
Contributor Author

@jvillafanez thanks for confirming, that's exactly what I thought.

@PVince81

Copy link
Copy Markdown
Contributor Author

Trying to debug this, seems we got a rabbit hole bug... looks like another file cache bug got revealed through this...

@PVince81

Copy link
Copy Markdown
Contributor Author

ok got it. seems some tests or the mock might be returning "null" as quota which is misinterpreted as zero.

Fix will follow, also for the backport PR

@PVince81

Copy link
Copy Markdown
Contributor Author

added null check when reading from config

@PVince81

Copy link
Copy Markdown
Contributor Author

ok, a few more to go...

There were 3 failures:

1) OCA\Files_Versions\Tests\VersioningTest::testRename
Failed asserting that false is true.

/srv/www/htdocs/owncloud/apps/files_versions/tests/VersioningTest.php:345

2) OCA\Files_Versions\Tests\VersioningTest::testRenameInSharedFolder
Failed asserting that false is true.

/srv/www/htdocs/owncloud/apps/files_versions/tests/VersioningTest.php:393

3) OCA\Files_Versions\Tests\VersioningTest::testCopy
Failed asserting that false is true.

/srv/www/htdocs/owncloud/apps/files_versions/tests/VersioningTest.php:556

FAILURES!
Tests: 20, Assertions: 153, Failures: 3.
make: *** [Makefile:179: test-php] Error 1

But first: 🍔

@PVince81

Copy link
Copy Markdown
Contributor Author

fixed versions too by bringing back the old code there.

I wonder if I should maybe change the code for trashbin and versions to use OC_Util::getUserQuota instead

@PVince81

Copy link
Copy Markdown
Contributor Author

Just retested and there is one remaining issue: when setting the quota to "default" in the users page, it sometimes switches to the actual default value instead of staying "default".
I see that the account table does contain the value "default" so it might be in a different layer.

@PVince81

Copy link
Copy Markdown
Contributor Author

AHA, the column first contains NULL which is not properly mapped to "default". Only once I set it to "default" explicitly it becomes "default".

@PVince81

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 FYI 0bd3418

interpretation of quota is up to a higher layer

@PVince81

Copy link
Copy Markdown
Contributor Author

Set default quota to 5 GB

  • TEST: newly created user in account table with "Null" sees "default" quota in users page, default quota properly applies in personal page, 5 GB
  • TEST: set user quota to "default", explicit "default" in account table, properly applies in personal page, 5 GB
  • TEST: set user quota to "unlimited", explicit "none" in account table, properly applies in personal page (unlimited)
  • TEST: set user quota to "1 GB", properly applies in personal page

@PVince81

Copy link
Copy Markdown
Contributor Author

Interestingly the even users who had "default" explicitly set are getting NULL in the accounts table. Doesn't hurt.

Please re-review

@PVince81

Copy link
Copy Markdown
Contributor Author

@individual-it weird thing that the quota UI tests fail on Firefox but not Chrome ?

Comment thread apps/files_trashbin/lib/Trashbin.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about using Util::getUserQuota(...) and have all this calculations in one place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

at first I thought it wouldn't work because getUserQuota doesn't return null but would return SPACE_UNLIMITED. But I could just use that value for the below check.

I'll have a try.

@PVince81

Copy link
Copy Markdown
Contributor Author

@jvillafanez 29e8cd3

@PVince81

Copy link
Copy Markdown
Contributor Author

stable9.1: #27896

(also updated)

@jvillafanez

Copy link
Copy Markdown
Member

Code looks fine 👍

Vincent Petry added 3 commits May 16, 2017 17:42
User::getQuota() and User::setQuota() are now reading the exact value as
set in the database instead of interpreting it. This is how it used to
behave.

Util::getUserQuota() is the method that interprets the quota for example
by replacing a default value with the default quota value from the app
config.
@PVince81

Copy link
Copy Markdown
Contributor Author

shake that CI

@lock

lock Bot commented Aug 3, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default quota value should be set to a oC user when we choose this option

3 participants