Skip to content

Shared Files filesize subtracted from quota + fix/patch #2796

Closed

Description

@tron65

Expected behaviour

User A has quota of 5GB
User B has quota of 5GB

User A owns files of summary size 2GB
User B owns files of summary size 4GB

User B shares 3GB with User A

User A has still 3GB free space

Actual behaviour

User A has no free space left, his 2GB + Shared 3GB fill up his quota

Steps to reproduce

should be obvious from the above

Server configuration

Operating system:
Debian Wheezy

Web server:
apache 2.2.22-13

Database:
mysql 5.5.30+dfsg-1

PHP version:
php5 5.4.4-14

ownCloud version:
5.0.3-0

fix:

for file lib/helper.php

--- helper.php.orig     2013-04-08 20:15:12.071656928 +0200
+++ helper.php  2013-04-08 20:15:51.506027881 +0200
@@ -801,7 +801,8 @@
         */
        public static function getStorageInfo() {
                $rootInfo = \OC\Files\Filesystem::getFileInfo('/');
-               $used = $rootInfo['size'];
+               $sharedInfo = \OC\Files\Filesystem::getFileInfo('/Shared');
+               $used = $rootInfo['size'] - $sharedInfo['size'];
                if ($used < 0) {
                        $used = 0;
                }

for file lib/fileproxy/quota.php


--- quota.php.orig      2013-04-08 20:08:48.663494593 +0200
+++ quota.php   2013-04-08 20:12:26.102512891 +0200
@@ -75,7 +75,13 @@
                $view = new \OC\Files\View("/".$owner."/files");

                $rootInfo = $view->getFileInfo('/');
+               $sharedInfo = $view->getFileInfo('/Shared');
+
                $usedSpace = isset($rootInfo['size'])?$rootInfo['size']:0;
+               $sharedSpace = isset($sharedInfo['size'])?$sharedInfo['size']:0;
+
+               $usedSpace = $usedSpace - $sharedSpace;
+
                return $totalSpace - $usedSpace;
        }

Activity

  1. DeepDiver1975 commented on Apr 8, 2013

    @DeepDiver1975
    Contributor

    @tron65 can you please submit a pull request? THX

  2. Niduroki commented on Apr 8, 2013

    @Niduroki
  3. tron65 commented on Apr 9, 2013

    @tron65
    Author

    @DeepDiver1975 i wanted to avoid having to do all the git stuff, as i am not really programming these days. it will take some time for me to get accustomed to it.

    anyway, pull request submitted

  4. BernhardPosselt commented on Apr 9, 2013

    @BernhardPosselt
    Contributor

    Please reopen if #2804 didnt fix it for you

  5. gpothier commented on Jun 12, 2013

    @gpothier

    The problem still occurs here with v5.0.7 installed from the Ubuntu 13.04 packages: shared files use the quotas of the owner and the users the files are shared with. Is this a regression? It seems the fix was released at version 5.0.5, but I have never used ownCloud before 5.0.7.

  6. tron65 commented on Jun 12, 2013

    @tron65
    Author

    the patch/subsequent pull was never incorporated into the main trunk it seems, for whatever reason, at least it is not in the debian packages @ deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_6.0/ /
    i am sure the maintainers have a reason for that, even if it is not clear to me why :)

  7. DeepDiver1975 commented on Jun 12, 2013

    @DeepDiver1975
    Contributor

    @tron65 your pull request was rejected - feel free to re-start the discussion in #2804 - THX

  8. DeepDiver1975 commented on Jul 25, 2013

    @DeepDiver1975
    Contributor

    I'm reopening this issue as it looks like it has not yet been solved

  9. DeepDiver1975 commented on Jul 25, 2013

    @DeepDiver1975
    Contributor

    @VicDeo @bantu any free time at the moment to take a look? Please evaluate if #2804 is a possible solution.
    In addition: please test the quota with mounted storages

  10. bantu commented on Jul 25, 2013

    @bantu

    @DeepDiver1975 Please confirm the expected behaviour (quota for user A only considers files owned by A).

  11. DeepDiver1975 commented on Jul 25, 2013

    @DeepDiver1975
    Contributor

    @bantu hehe - good point - we need a clear definition of quota actually.

    From my understanding the quota should only apply to the users primary local dataspace (stuff under /data/${user}/files).
    Shared files are not to be counted.
    Same for external mounted file systems - we actually might need another quota on external storages

    @karlitschek @jancborchardt your opinion

  12. jancborchardt commented on Jul 25, 2013

    @jancborchardt
    Contributor

    I completely agree with how @DeepDiver1975 describes storage management should work. Because files shared with me are not duplicated onto my storage, it should not take away from that. Same for external storages – the data is never duplicated onto my storage either.

    While versions and deleted files reside on my storage, they are »shadow files« which will make way for actual data once it’s needed. Hence no need to visualize or inform that I think. (At least not at this point.) cc @schiesbn – but most definitely, versions and deleted files do not count towards storage use either.

  13. jancborchardt commented on Jul 25, 2013

    @jancborchardt
    Contributor

    Also cc @MTRichards and @owncloud/designers for info, see my previous comment.

  14. MTRichards commented on Jul 25, 2013

    @MTRichards
    Contributor

    For now, as long as we are consistent, I agree with @jancborchardt . As shadow files do not count against quota, we should keep that behavior. However, there are circumstances where you do want them to count against quota. What I would LOVE is a configurable option - so that it can be set by the administrator at the site level in the admin panel.
    Example: For this instance of ownCloud, quota should: include files shared with me; only include files I own.

    We also have the sticky problem of whether external storage counts against quota or not - but this is an issue to solve later.

  15. jancborchardt commented on Jul 26, 2013

    @jancborchardt
    Contributor

    However, there are circumstances where you do want them to count against quota.

    What are those circumstances? Because if it a file is not actually on the hard drive space reserved for me, it does not seem to make sense to act like it is.

    Especially because it is so certain to determine »does this file reside on my storage: yes or no?« (or is it?) a preference seems like making it more complicated than it actually is – which is just having it in the code.

  16. stephanarts commented on Aug 12, 2013

    @stephanarts
    Contributor

    @jancborchardt I agree with you.

    In our configuration we have a group that contains ALL users. If one of our 1800 users would choose to share a file
    of 1GB with that group. Nobody would be able to use it. I would consider this a DoS ;-)

  17. mbremer commented on Aug 13, 2013

    @mbremer

    Indeed, at the moment I can't put files onto my owncloud storage, because someone shared his maximum amount of storage (1 GB) with me. I only have 10 MB in use and still my quota is exceeded. It should only count the files that you own.

  18. jturmelle commented on Sep 12, 2013

    @jturmelle

    Its not clear to me if there is a short term plan to fix the current bug of shared storage counting against an individual's quota. The fact, referenced many times in these threads, that you can go over your quota without ever adding a file, shows that quotas are unusable. I've looked at all the references and it seems that fixes aren't planned until OC6 or OC7.

  19. karlitschek commented on Oct 22, 2013

    @karlitschek
    Contributor

    We need a config switch for that. You want to count the shared folder sometimes and sometimes not.

  20. PVince81 commented on Nov 5, 2013

    @PVince81
    Contributor

    Which one is the most common use case ?

    I think it shouldn't be possible for people to "pollute" your storage.

    Also, if user1 has 1 GB quota and user2 has 1 GB quota, and the total hard disk space is 2 GB. Currently if user2 shares 1 GB with user1, user1 won't be able to upload anything, which means that 1 GB hard disk space will be available forever, wasted.

    Can we make the "not counting /Shared" in a user's quota the default ? The switch (if easy to add) will switch it back to the current behavior.

    I'll have a look how difficult it is to implement as it is affecting another fix of mine.

  21. PVince81 commented on Nov 5, 2013

    @PVince81
    Contributor

    I just had a try with OC 6 Beta 2 (master) and it seems shared files aren't counted in the actual quota.
    BUT whatever is displayed in the UI is wrong.

    Steps:

    1. Create two users, user1 and user2 and set their quota to 100 MB
    2. Login as user1, upload a 90 MB file
    3. Share the file with user2
    4. Login as user2
    5. Upload a 50 MB file
    6. Upload a 60 MB file

    At step 5, the file goes through.
    At step 6, it doesn't since 50+60 > 100 MB.
    The 90 MB file that is in the Shared dir didn't count.

    Which means this seems to be fixed already in OC6 but the UI needs to be fixed to show the correct values, there's a PR for that already: #5399

    Can someone confirm this ?

  22. PVince81 commented on Nov 5, 2013

    @PVince81
    Contributor

    I've done some tests to try and check all use cases and see whether they work consistently with the idea that the file/dir owner is the one whose quota is affected.

    Case A: Regular quota without sharing.

    ✅ Works

    Case B: File sharing

    user1 shares file F with user2.
    Size of file F counts in user1's quota.

    ✅ Works in OC6.

    Case C: Shared dir with write permissions

    user1 shares directory D with user2.
    user2 uploads file F into directory.

    ✅ Works in OC6 beta 5
    Raised as #5697

    Case D: Public dir with write permissions

    user1 shared directory D with public link, with upload enabled.
    external user uploads file F into D using the public link.

    ✅ Works in OC6: the file F is counted against user1's quota.
    Can't upload a file that would exceed the quota.

    Case E: total used space shown in files list

    ✅ Works correctly in OC6. Was fixed by PR #5399

    Case F: total used space shown in personal page

    ✅ Works correcly in OC6 beta 5. Fixed by #5927

  23. friscoMad commented on Nov 5, 2013

    @friscoMad
    Contributor

    I have made some more tests with reshared folders with write permissions and there are no difference from shared regular shared folders.
    Some of the problems with max upload size and notifications are fixed with #5387 but I have found that it still shows your remaining quota for uploads in shared folders with write permissions (owner remaining quota should be used there).

  24. friscoMad commented on Nov 5, 2013

    @friscoMad
    Contributor

    Also found that after creating a user with quota it takes some time until it is applied and until then the user quota is 0b
    screenshot 99
    The first time I was even able to go to personal preferences and there it was a 0 of ? too but after rebasing to lastest master I can only reproduce this issue.

  25. PVince81 commented on Nov 5, 2013

    @PVince81
    Contributor

    Yes, I'm aware of these issues. Unfortunately still too many to fix.
    I'll have a look at the quota calculation related to share folder in #5697.
    The issue from your screenshot should be fixed by #5684

    The quota calculation is based on the size of the root folder in the database. If that one is either wrong or set to -1 (during a scanning process), then the quota will be either wrong or 0.

  26. PVince81 commented on Nov 25, 2013

    @PVince81
    Contributor

    Quota issues have been fixed in OC 6 beta 5. See #2796 (comment) for details.

    If you meet new problems please raise new issues.
    Thanks.

  27. locked as resolved and limited conversation to collaborators on Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions