[Bug]: Remove empty folders in files_versions
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
the occ versions:expire command correctly deletes files that no longer correspond to the rules, but if the folder is empty, it is not deleted.
Steps to reproduce
- Set versions expiration rule
- Create a folder called "test_folder", create inside "test_folder" a file called "test_file.txt"
- create a second version of "test_file"
- check that nextcloud has created a file called "test_file.docx.vXXXXXX" in your user "files_versions/test_folder/" folder
- wait for the expiry rule to pass
- execute
occ versions:expire -vvv - go back and check the "files_versions" folder and you'll see that the "test_folder" folder is still there, but no longer contains any versions. So the folder is empty but still exists.
Expected behavior
When the version file contained in a folder is deleted and the folder is empty, this folder must be deleted.
Installation method
Community Manual installation with Archive
Nextcloud Server version
29
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
Apache (supported)
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
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
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"***REMOVED SENSITIVE VALUE***"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "29.0.4.1",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"maintenance": false,
"theme": "",
"loglevel": 1,
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379,
"dbindex": 0,
"timeout": 0
},
"mysql.utf8mb4": true,
"mail_smtpmode": "smtp",
"mail_smtpsecure": "ssl",
"mail_sendmailmode": "smtp",
"mail_smtpauthtype": "LOGIN",
"mail_smtpauth": 1,
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "465",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"maintenance_window_start": 1,
"default_phone_region": "BE",
"app_install_overwrite": [
"groupfolders",
"ransomware_protection"
],
"versions_retention_obligation": "auto, 30",
"trashbin_retention_obligation": "auto, 30"
}
}
List of activated Apps
Enabled:
- activity: 2.21.1
- admin_audit: 1.19.0
- bruteforcesettings: 2.9.0
- cloud_federation_api: 1.12.0
- comments: 1.19.0
- contactsinteraction: 1.10.0
- dav: 1.30.1
- federatedfilesharing: 1.19.0
- files: 2.1.0
- files_downloadlimit: 2.0.0
- files_pdfviewer: 2.10.0
- files_reminders: 1.2.0
- files_sharing: 1.21.0
- files_trashbin: 1.19.0
- files_versions: 1.22.0
- firstrunwizard: 2.18.0
- groupfolders: 17.0.1
- logreader: 2.14.0
- lookup_server_connector: 1.17.0
- nextcloud_announcements: 1.18.0
- notifications: 2.17.0
- oauth2: 1.17.0
- password_policy: 1.19.0
- photos: 2.5.0
- privacy: 1.13.0
- provisioning_api: 1.19.0
- ransomware_protection: 1.14.0
- recommendations: 2.1.0
- related_resources: 1.4.0
- serverinfo: 1.19.0
- settings: 1.12.0
- sharebymail: 1.19.0
- support: 1.12.0
- survey_client: 1.17.0
- text: 3.10.1
- theming: 2.4.0
- twofactor_backupcodes: 1.18.0
- updatenotification: 1.19.1
- user_status: 1.9.0
- viewer: 2.3.0
- workflowengine: 2.11.0
Disabled:
- circles: 29.0.0-dev (installed 0.20.7)
- dashboard: 7.9.0 (installed 6.0.0)
- encryption: 2.17.0
- federation: 1.19.0 (installed 1.5.0)
- files_external: 1.21.0
- files_rightclick: 0.15.1 (installed 1.6.0)
- passwords: 2024.7.20 (installed 2024.7.20)
- suspicious_login: 7.0.0
- systemtags: 1.19.0 (installed 1.5.0)
- twofactor_totp: 11.0.0-dev
- user_ldap: 1.20.0
- weather_status: 1.9.0 (installed 1.0.0)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
No response
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the files_versions app at the occ versions:expire command and reproduce the scenario with a versioned file inside a folder. Trace the expiry cleanup and verify that, once the last version is removed, its now-empty folder is also removed; rerun the command and confirm the files_versions directory contains no empty folder.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100