Skip to content

User of remaining capacity limit at the time of the 0 byte, not be able to delete the files on the shared folder. #16187

Closed

Description

@pomu0326

Steps to reproduce

  1. Create a USER_A, and set the quota to 5GB.
  2. Create a USER_B, and set the quota to 0.
  3. USER_A create a folder, you will share the folder to USER_B.
  4. USER_B Upload the file of something in a shared folder.
  5. USER_B deletes the file.

Expected behaviour

I expect that the file can be deleted.

Actual behaviour

owncloud will cause an error.

Could not delete: [target file]

Server Host info

Ubuntu 14.04
PHP 5.5.9
MariaDB 10.0.17

Server configuration

The default setting of owncloud 8.0.3

Activity

  1. MorrisJobke commented on May 8, 2015

    @MorrisJobke
    Contributor

    I guess, this is because of the file should be moved to its trashbin and because of an quota of 0 this isn't possible.

    cc @icewind1991 @schiesbn @PVince81

  2. Octopus2 commented on May 8, 2015

    @Octopus2

    Perhaps a duplicate of this one: owncloud/client#3010

    You can´t delete a shared file if the quota is smaler than the filesize

  3. MorrisJobke commented on May 8, 2015

    @MorrisJobke
    Contributor

    @nickvergessen Maybe you want to dig into this? :D

  4. Octopus2 commented on May 26, 2015

    @Octopus2

    @MorrisJobke Any news on this?

    This is an annoying error when you mainly use ownCloud for working togeter on shared files (Userquota only 10MB) and you can´t delete bigger files any more...

  5. pomu0326 commented on May 26, 2015

    @pomu0326
    Author

    @Octopus2 Hi, this is my workaround.
    However, it does not rest files in the trashbox if the quota is not enough.

    /lib/private/files/storage/wrapper/quota.php (origin)

        public function fopen($path, $mode) {
            $source = $this->storage->fopen($path, $mode);
            $free = $this->free_space('');
            if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
                return \OC\Files\Stream\Quota::wrap($source, $free);
            } else {
                return $source;
            }
        }

    /lib/private/files/storage/wrapper/quota.php (workaround)

        public function fopen($path, $mode) {
            $source = $this->storage->fopen($path, $mode);
            $free = $this->free_space('');
            if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
                            //remove origin code
                            //return \OC\Files\Stream\Quota::wrap($source, $free);
    
                            // add workaround. If in the case of trashbin, it will ignore the quotas.
                            if (strpos($path, 'files_trashbin/', 0) === 0) {
                                    return $source;
                            } else {
                                    return \OC\Files\Stream\Quota::wrap($source, $free);
                            }
            } else {
                return $source;
            }
        }
  6. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    I'd like to increase severity. There are use cases where people share folders with other users, and those users can only work on the shared folders but not have any local files. This is achieved by setting their quota to 0, see #16599 (comment)

    When deleting a shared file as recipient, usually that file will land in the recipient's trashbin and also in the owner's trashbin. If the recipient doesn't have enough space, I'd expect the file to not reach the recipient's trashbin, but still reach the one from the owner.

    Seems to be a bug.

    I don't think @pomu0326's workaround is the right way, because I suspect it might happen if the quota is set to low values like a few bytes, or whenever that user's free space is very low.

  7. added this to the milestone on May 28, 2015
  8. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    @mattrandallbecker mentionned here #16599 (comment) that it used to work in OC 6/7, so this is a regression.

  9. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    It is likely that the regression is due to the fact that the trashbin is now using a storage wrapper since OC 8.0

  10. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    Confirmed that it works on stable7 (upcoming 7.0.6).
    The file does not appear in the recipient's trashbin, but it appears in the owner's trashbin.
    However, the file in the trashbin has a size of zero bytes 😦

    On stable8 (upcoming 8.0.4), I cannot delete the file.
    This confirms this bug report and is indeed a regression.

  11. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    @pomu0326 you got a point: from reading your change it looks like the quota storage wrapper was getting applied to the trashbin, which is wrong.

    I'll see if I can provide a fix a bit higher in the call stack.

  12. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    not saying that your fix is wrong, but it shows very well what is wrong in the original code 😄

  13. self-assigned this
    on May 28, 2015
  14. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    Hmmm on master (upcoming 8.1) the behavior is slightly different: I do get a "Could not delete" error, but after refresh the file is gone. But it's not even in the owner's trashbin! 😦

  15. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    This is the call stack that leads to the quota wrapper for trashbin:

    0  OC\Files\Stream\Quota::wrap() /srv/www/htdocs/owncloud/lib/private/files/stream/quota.php:68
    1  OC\Files\Storage\Wrapper\Quota->fopen() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/quota.php:144
    2  OC\Files\Storage\Wrapper\Encryption->fopen() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/encryption.php:406
    3  OC\Files\Storage\Wrapper\Encryption->copyBetweenStorage() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/encryption.php:476
    4  OC\Files\Storage\Wrapper\Encryption->moveFromStorage() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/encryption.php:424
    5  OC\Files\Storage\Wrapper\Wrapper->moveFromStorage() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/wrapper.php:534
    6  OCA\Files_Trashbin\Trashbin::move2trash() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/trashbin.php:199
    7  OCA\Files_Trashbin\Storage->doDelete() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/storage.php:125
    8  OCA\Files_Trashbin\Storage->unlink() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/storage.php:89
    9  OC\Files\View->basicOperation() /srv/www/htdocs/owncloud/lib/private/files/view.php:938
    10 OC\Files\View->unlink() /srv/www/htdocs/owncloud/lib/private/files/view.php:573
    11 OC\Files\Filesystem::unlink() /srv/www/htdocs/owncloud/lib/private/files/filesystem.php:677
    12 require_once()  /srv/www/htdocs/owncloud/apps/files/ajax/delete.php:59
    13 __lambda_func() /srv/www/htdocs/owncloud/lib/private/route/route.php%28153%29%20:%20runtime-created%20function:1
    14 call_user_func:{/srv/www/htdocs/owncloud/lib/private/route/router.php:272}() /srv/www/htdocs/owncloud/lib/private/route/router.php:272
    15 OC\Route\Router->match() /srv/www/htdocs/owncloud/lib/private/route/router.php:272
    16 OC::handleRequest() /srv/www/htdocs/owncloud/lib/base.php:862
    17 {main}          /srv/www/htdocs/owncloud/index.php:40
    

    Now one thing I don't yet understand is how could this have ever worked ?

    I found out that stable7 also wraps the storage, but it doesn't seem to disturb the trashbin in the same way:

    0  OC\Files\Storage\Wrapper\Quota->fopen() /srv/www/htdocs/owncloud/lib/private/files/storage/wrapper/quota.php:127
    1  OC\Files\View->basicOperation() /srv/www/htdocs/owncloud/lib/private/files/view.php:778
    2  OC\Files\View->fopen() /srv/www/htdocs/owncloud/lib/private/files/view.php:665
    3  OC\Files\View->copy() /srv/www/htdocs/owncloud/lib/private/files/view.php:603
    4  OCA\Files_Trashbin\Trashbin::copy_recursive() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/trashbin.php:866
    5  OCA\Files_Trashbin\Trashbin::move2trash() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/trashbin.php:127
    6  OCA\Files_Trashbin\Hooks::remove_hook() /srv/www/htdocs/owncloud/apps/files_trashbin/lib/hooks.php:42
    7  call_user_func:{/srv/www/htdocs/owncloud/lib/private/hook.php:78}() /srv/www/htdocs/owncloud/lib/private/hook.php:78
    8  OC_Hook::emit() /srv/www/htdocs/owncloud/lib/private/hook.php:78
    9  OC\Files\View->runHooks() /srv/www/htdocs/owncloud/lib/private/files/view.php:853
    10 OC\Files\View->basicOperation() /srv/www/htdocs/owncloud/lib/private/files/view.php:774
    11 OC\Files\View->unlink() /srv/www/htdocs/owncloud/lib/private/files/view.php:433
    12 OC\Files\Filesystem::unlink() /srv/www/htdocs/owncloud/lib/private/files/filesystem.php:633
    13 require_once()  /srv/www/htdocs/owncloud/apps/files/ajax/delete.php:31
    14 OC::loadAppScriptFile() /srv/www/htdocs/owncloud/lib/base.php:809
    15 call_user_func:{/srv/www/htdocs/owncloud/lib/private/route/router.php:227}() /srv/www/htdocs/owncloud/lib/private/route/router.php:227
    16 OC\Route\Router->match() /srv/www/htdocs/owncloud/lib/private/route/router.php:227
    17 OC::handleRequest() /srv/www/htdocs/owncloud/lib/base.php:717
    18 {main}          /srv/www/htdocs/owncloud/index.php:28
    

    Well... it does produce a zero-sized file in the trashbin.

    So I could say, basically this was broken in previous versions too, but in a different way...

  16. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    One idea would be to adapt @pomu0326's idea but only apply the quota wrapper if the path is in "/files/". Because we also do not want to apply the quota on "files_encryption", "thumbnails", etc.

  17. PVince81 commented on May 28, 2015

    @PVince81
    Contributor

    Fix is here: #16613

  18. pomu0326 commented on Jun 1, 2015

    @pomu0326
    Author

    @PVince81 thank you. I was able to resolve the issue.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions