nextcloud / nextcloud/server

[Bug]: Files from user directory lost when added to grup with groupfolder of the same name

Open
#59,619 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 32-feedback bug hotspot: filename handling
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

If there's an users directory named for example 'aaa' in user's main directory, and one creates a group directory named 'aaa' and adds the user to the group, the user's directory 'aaa' gets correctly renamed to 'aaa (1)' (looks like intended behaviour to avoid name conflicts) and all subdirectories of 'aaa' get moved to 'aaa (1)', but files get lost. The files get removed from local drives by Nextcloud client apps.

Steps to reproduce
  1. Create directory named 'aaa' in user's main directory. Create subdir 'aaa/bbb' and 'aaa/ccc'. Make some test files inside subdirs.
  2. Make grup directory 'aaa' owned by a group
  3. Add the user to the grup
  4. The user's 'aaa' directory gets renamed to 'aaa (1)', and all directories from the original 'aaa' dir ('aaa/bbb' and 'aaa/ccc') will be moved to 'aaa (1)/bbb' and 'aaa (1)/ccc', but with no files inside.
  5. The test files get removed from local drives by the Nextcloud local clients.
  6. The new 'aaa' group directory remains empty.
Expected behavior

I expect the renamed, user's directory 'aaa (1)' contains same directory and files as the original 'aaa' directory.

Nextcloud Server version

32

Operating system

Debian/Ubuntu

PHP engine version

None

Web server

None

Database engine version

None

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

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status
No errors have been found.
Nextcloud Logs
Warning
PHP
Undefined array key "node" at /var/www/html/custom_apps/notes/lib/Service/NoteUtil.php#201

14 kwi 2026, 09:31:26

Error
core
unable to rename, file does not exists : files/OTAS

14 kwi 2026, 09:27:17

Error
no app in context
TypeError
readdir(): Argument #1 ($dir_handle) must be of type resource or null, false given

14 kwi 2026, 09:27:17

Error
webdav
TypeError
readdir(): Argument #1 ($dir_handle) must be of type resource or null, false given

14 kwi 2026, 09:27:17

Warning
PHP
opendir(/mnt/ncdata/maciek/files/OTAS): Failed to open directory: No such file or directory at /var/www/html/lib/private/Files/Storage/Local.php#130

14 kwi 2026, 09:27:17

Warning
PHP
Attempt to read property "name" on null at /var/www/html/custom_apps/integration_openproject/lib/Controller/ConfigController.php#494

14 kwi 2026, 09:09:57
Additional info

Nextcloud Hub 25 Autumn (32.0.8)
Running in Nextcloud AIO.

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

Reproduce the conflict using the six listed steps, then start at lib/private/Files/Storage/Local.php around line 130 and review the rename and directory traversal behavior. Check the related WebDAV and core log errors while tracing the move. Done means the renamed user directory retains both its subdirectories and files, while the group directory remains available.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.