owncloud-archive / mozilla_sync

GNU Affero General Public License v3.0
119 stars 23 forks source link

Implement quotas #32

Closed ogasser closed 10 years ago

ogasser commented 10 years ago

Implement quotas to limit the space used by users. This setting would be configured in the admin panel on a per user or group basis. The quota API call is already implemented, but it always returns no quota. By default quota limitations are disabled.

RoboMod commented 10 years ago

I would like to work on this issue.

ogasser commented 10 years ago

Go for it! PS: Create a new branch forked from mozilla_sync_1.2 to allow for easier merging.

RoboMod commented 10 years ago

Where can I find the existing qouta API?

ogasser commented 10 years ago

The info/quota call can be found in lib/storageservice.php.

ogasser commented 10 years ago

See also Mozilla's docs for HTTP status codes and response codes.

RoboMod commented 10 years ago

I implemented the quota limit (see 1b9295b). But I have 2 things to discuss:

  1. validation of the limit input, how can I do this efficient in OC?
  2. calculation of the input data size. When postCollection or putWBO are called, there is now a check if the existing quota is higher or equal to the limit. But maybe the data to save is too much, so the limit would be exceeded. Do you know an easy way to calculate the input data size?
ogasser commented 10 years ago

Your link does not point to the correct commit, this should be it RoboMod/mozilla_sync@c4ae663d2321c586ee812e8d6b0790d9cf7b26f6

It will make the work on your part easier if you create a new branch for each issue/feature you are working on. Additionally, the merging process would be clearer ;)

Regarding your questions:

  1. If you mean to validate the input sent in the AJAX request you can use filter_var().
  2. You can check the length of the payload and simply add that to the already existing data in the database.

We have a major desgin question to answer: Did you envision to set a global quota limit or per user quotas?

Regarding the code I have some comments. I posted them inline in your commit and also here:

RoboMod commented 10 years ago

Thank your for the comments.

I will move my commits to a new branch. To the first question: What I ment wasn't the AJAX php input. I think it would be nice for the user to get an instant response when typing characters instead of numbers to the input line. Is there a "standard" OC solution for that? Regarding the code: I will try to work in your tips.

My idea about the major deisgn question was to first add a global quota limit. Maybe we could add a per use quota later, if that feature is needed or requested by anyone.

ogasser commented 10 years ago

I appreciate your effort to integrate the tips into the code!

For input validation you use indeed AJAX. That means that the quota is send to the server, the server validates it and then sends a response. Have a look at the ownCloud core code to see how the email verification on the personal page is done.

I aggree with you on the design decision. User specific quotas make it more complex from a database and especially UI design perspective. So starting with a global quota seems reasonable to me.

RoboMod commented 10 years ago

Okay, now your comments are worked in (ab1a1cd). If your are okay with the code, I will do a pull request.

PS: I will switch the branch for the next issues I'll work on. ;)

ogasser commented 10 years ago

I added some more comments to your code. You can always send a pull request. We can then discuss the issue on the pull request and additional changes can just be pushed to the pull-request specific branch.

ogasser commented 10 years ago

Merged code by @RoboMod into the mozilla_sync_1.2 branch.