nextcloud / nextcloud/server

[Bug]: Shared subfolder duplicated in trash bin

Open
#50,267 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 30-feedback bug feature: sharing feature: trashbin
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

When a user (not the owner) delete a shared subfolder, the folder is copied in the owner trash bin, but also in the user one.
This duplicate all the files if possible.
If the user does not have enough quota, this result in an error and only partial files present in his trash bin.

If the user tries to restore the subfolder, this will be restored in his home folder and not the shared folder with potential files missing or no files at all.

This is not the same as deleting a file, the file is only present in the owner trash bin, that seems to be the right behavior.

Steps to reproduce
  1. User 1 (big quota) share a folder with User 2
  2. User 1 create a subfolder with multiples files in it, the total exceeds the User 2 quota
  3. User 2 (small quota) delete the subfolder
Expected behavior

The folder is only present in the owner trash bin, no error caused by the user quota and no duplicated files in the trash bin

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

SQlite

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 28 to 29)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "upgrade.disable-web": true,
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "sqlite3",
        "version": "30.0.5.1",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 2,
        "maintenance": false
    }
}
List of activated Apps
Enabled:
  - activity: 3.0.0
  - app_api: 4.0.5
  - bruteforcesettings: 3.0.0
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contactsinteraction: 1.11.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - nextcloud_announcements: 2.0.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - encryption: 2.18.0
  - files_external: 1.22.0
  - suspicious_login: 8.0.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"Jghk6On8RRIYBmN8bvh9","level":3,"time":"2025-01-20T11:26:35+00:00","remoteAddr":"172.19.0.1","user":"test","app":"webdav","method":"DELETE","url":"/remote.php/dav/files/test/Test/Subfolder","message":"Exception thrown: OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0","version":"30.0.5.1","exception":{"Exception":"OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException","Message":"","Code":0,"Trace":[{"file":"/var/www/html/apps/files_trashbin/lib/Trashbin.php","line":185,"function":"copy_recursive","class":"OCA\\Files_Trashbin\\Trashbin","type":"::","args":["fcharlaix/files_trashbin/files/Subfolder.d1737372395","test/files_trashbin/files/Subfolder.d1737372395",{"__class__":"OC\\Files\\View"}]},{"file":"/var/www/html/apps/files_trashbin/lib/Trashbin.php","line":336,"function":"copyFilesToUser","class":"OCA\\Files_Trashbin\\Trashbin","type":"::","args":["/Test/Subfolder","fcharlaix","Test/Subfolder","test",1737372395]},{"file":"/var/www/html/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php","line":95,"function":"move2trash","class":"OCA\\Files_Trashbin\\Trashbin","type":"::","args":["Test/Subfolder"]},{"file":"/var/www/html/apps/files_trashbin/lib/Trash/TrashManager.php","line":85,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend","type":"->","args":[{"__class__":"OCA\\Files_Trashbin\\Storage","cache":null,"scanner":null,"watcher":null,"propagator":null,"updater":null},"Subfolder"]},{"file":"/var/www/html/apps/files_trashbin/lib/Storage.php","line":168,"function":"moveToTrash","class":"OCA\\Files_Trashbin\\Trash\\TrashManager","type":"->","args":[{"__class__":"OCA\\Files_Trashbin\\Storage","cache":null,"scanner":null,"watcher":null,"propagator":null,"updater":null},"Subfolder"]},{"file":"/var/www/html/apps/files_trashbin/lib/Storage.php","line":90,"function":"doDelete","class":"OCA\\Files_Trashbin\\Storage","type":"->","args":["Subfolder","rmdir"]},{"file":"/var/www/html/lib/private/Files/View.php","line":1136,"function":"rmdir","class":"OCA\\Files_Trashbin\\Storage","type":"->","args":["Subfolder"]},{"file":"/var/www/html/lib/private/Files/View.php","line":286,"function":"basicOperation","class":"OC\\Files\\View","type":"->","args":["rmdir","/Test/Subfolder",["delete"]]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php","line":271,"function":"rmdir","class":"OC\\Files\\View","type":"->","args":["/Test/Subfolder"]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php","line":197,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":[]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":281,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->","args":["files/test/Test/Subfolder"]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:DELETE",[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Server.php","line":43,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":371,"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":19,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":146,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/files_trashbin/lib/Trashbin.php","Line":944,"message":"","exception":[],"CustomMessage":"Exception thrown: OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException"},"id":"678e3300ce535"}
Additional info

This was reproduced in Debian prod 28, and in docker test environment 28, 29 and 30

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/files_trashbin/lib/Trashbin.php, especially copyFilesToUser and the move2trash path shown in the trace. Reproduce the shared-subfolder deletion with users having different quotas, then verify that only the owner's trash bin contains the folder, no quota error occurs, and restoration does not create an unrelated home-folder copy.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.