Skip to content

Allow to set the trash bin size to a percentage value of the available disk space and to reset it to the default value #22549

Open

Description

@j-ed

How to support this request?

  • Please use the 👍 reaction to show that you are also in favor of this feature - we are using this information to decide which features to include in upcoming Nextcloud versions.
  • Please don't comment if you have no relevant information to add

Expected behavior

The new occ command (trashbin:size) should allow to set the size of the trash bin to a percentage value of the available disk space and also allow to reset the value to the default of 50%.

Current behavior

The new occ command (trashbin:size) has been introduced to configure the size of the trash bin. This currently only seems to allow to set the size to a fixed size and doesn't allow to set a percentage value of the available disk space, nor does it allow to reset the value to the default of 50% of the available disk space.

  1. I haven't found a way to reset the parameter to the default value:
    > ./occ trashbin:size -1 => The "-1" option does not exist

  2. I haven't found a way to configure a percentage value of the available disk space:
    > ./occ trashbin:size 10% => Failed to parse input size

Steps to reproduce

  1. Open a command line session
  2. Execute the given command and see what happens

Environment

Server Configuration

OS: Linux 4.9.218
Web server: Apache2 2.4.46
Database: MariaDB 10.2.24
PHP version: 7.4.8
Nextcloud version: 19.0.2

Client Configuration

Browser: Mozilla Firefox 80.0.1
Operating system: Windows 10

Activity

  1. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Sep 2, 2020
  2. j-ed commented on Sep 2, 2020

    @j-ed
    ContributorAuthor

    @kesselb I've seen that you seem to work on related issues #22475 and #22528. It might be worse to fix these points too.

  3. kesselb commented on Sep 2, 2020

    @kesselb
    Contributor

    It might be worse to fix these points too.

    🤣

    reset the parameter to the default value:

    System: occ config:app:delete files_trashbin trashbin_size
    User: occ user:setting --delete $UID files_trashbin trashbin_size

    configure a percentage value of the available disk space:

    /**
    * Make a computer file size
    * @param string $str file size in human readable format
    * @return float|bool a file size in bytes
    *
    * Makes 2kB to 2048.
    *
    * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
    */
    public static function computerFileSize($str) {
    $str = strtolower($str);
    if (is_numeric($str)) {
    return (float)$str;
    }
    $bytes_array = [
    'b' => 1,
    'k' => 1024,
    'kb' => 1024,
    'mb' => 1024 * 1024,
    'm' => 1024 * 1024,
    'gb' => 1024 * 1024 * 1024,
    'g' => 1024 * 1024 * 1024,
    'tb' => 1024 * 1024 * 1024 * 1024,
    't' => 1024 * 1024 * 1024 * 1024,
    'pb' => 1024 * 1024 * 1024 * 1024 * 1024,
    'p' => 1024 * 1024 * 1024 * 1024 * 1024,
    ];
    $bytes = (float)$str;
    if (preg_match('#([kmgtp]?b?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
    $bytes *= $bytes_array[$matches[1]];
    } else {
    return false;
    }
    $bytes = round($bytes);
    return $bytes;
    }

    The input is parsed by the above method. Only absolute numbers are supported. Pull requests are always welcome but keep in mind that datadirectory might be on a different hard disk or object storage is used. To find right disk size is the difficult part here.

  4. j-ed commented on Sep 2, 2020

    @j-ed
    ContributorAuthor

    @kesselb Thank you for the explanation. I wouldn't have ever thought about using the config:app:delete or user:setting commands to reset a value for which an explicit trashbin:size command has been introduced. I think many other users will run into this trap too.
    In this case it would have been more intuitive to use the config:app:set or user:sitting:... way to set the parameters. If you think it isn't bug then it might be at least an enhancement request to get the syntax aligned with other other commands.

  5. szaimen commented on Jun 9, 2021

    @szaimen
    Contributor

    I suppose this issue is still valid?

  6. j-ed commented on Jun 10, 2021

    @j-ed
    ContributorAuthor

    Yes, I'm not aware about any changes.

  7. szaimen commented on Jan 23, 2023

    @szaimen
    Contributor

    Hi, this sounds more like a feature reqhest to me.

  8. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    and removed
    1. to developAccepted and waiting to be taken care of
    on Jan 23, 2023
  9. someone-somenet-org commented on Dec 15, 2025

    @someone-somenet-org

    Yes, please.
    Allow me to set the default-quota to 100% of the users' quotas, so when they delete everything in an almost full account by accident, they dont lose any files and can restore everything.

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