nextcloud / nextcloud/server

Expiring versions does not work for deleted files

Open
#40,450 12 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 27-feedback bug feature: trashbin feature: versions
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 Nextcloud tries to expire versions for files which got deleted, it will fail because it will try to find the original file which does not exist any longer. This is what I get when I try to run that for a specific user (all private data anonymized):

occ versions:expire USERNAME -vvv
Remove deleted files of   USERNAME

In Root.php line 206:

  [OCP\Files\NotFoundException]
  /path-example/filename


Exception trace:
  at /var/www/server.example/lib/private/Files/Node/Root.php:206
 OC\Files\Node\Root->get() at /var/www/server.example/lib/private/Files/Node/Folder.php:135
 OC\Files\Node\Folder->get() at /var/www/server.example/apps/files_versions/lib/Storage.php:595
 OCA\Files_Versions\Storage::OCA\Files_Versions\{closure}() at n/a:n/a
 array_filter() at /var/www/server.example/apps/files_versions/lib/Storage.php:610
 OCA\Files_Versions\Storage::expireOlderThanMaxForUser() at /var/www/server.example/apps/files_versions/lib/Command/ExpireVersions.php:110
 OCA\Files_Versions\Command\ExpireVersions->expireVersionsForUser() at /var/www/server.example/apps/files_versions/lib/Command/ExpireVersions.php:86
 OCA\Files_Versions\Command\ExpireVersions->execute() at /var/www/server.example/3rdparty/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/server.example/3rdparty/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /var/www/server.example/3rdparty/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/server.example/3rdparty/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/server.example/lib/private/Console/Application.php:211
 OC\Console\Application->run() at /var/www/server.example/console.php:100
 require_once() at /var/www/server.example/occ:11

versions:expire [<user_id>...]
Steps to reproduce
  1. create file
  2. make changes to, so that there are multiple versions
  3. delete the file
  4. run occ versions:expire

Note: I don't know if this will only happen, if there is at least one old version to be deleted.

Expected behavior

occ versions:expire and the respective background job work without any error message.

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

27.0.2, 27.1.0, 27.1.1, 27.1.3

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MariaDB

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

Updated from a MINOR version (ex. 22.1 to 22.2)

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": [
            "nextcloud.0x0c.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "",
        "overwrite.cli.url": "https:\/\/nextcloud.0x0c.de",
        "dbtype": "mysql",
        "version": "27.0.2.1",
        "installed": true,
        "htaccess.RewriteBase": "\/",
        "maintenance": false,
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "dbindex": 0
        },
        "knowledgebaseenabled": false,
        "theme": "",
        "simpleSignUpLink.shown": false,
        "loglevel": 2,
        "log_authfailip": true,
        "mysql.utf8mb4": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "sendmail",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "updater.release.channel": "stable",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 180",
        "app_install_overwrite": [
            "apporder",
            "deck",
            "keeweb",
            "appointments",
            "drawio",
            "bookmarks",
            "spreed",
            "unroundedcorners",
            "fulltextsearch",
            "fulltextsearch_elasticsearch",
            "files_fulltextsearch",
            "files_fulltextsearch_tesseract",
            "passwords",
            "gpxpod",
            "dicomviewer",
            "files_bpm"
        ],
        "has_rebuilt_cache": true,
        "default_language": "de",
        "default_phone_region": "DE",
        "check_data_directory_permissions": false,
        "log_rotate_size": 52428800,
        "profile.enabled": false,
        "preview_max_x": 1920,
        "preview_max_y": 1920,
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_smtpport": "465",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "reference_opengraph": false
    }
}
List of activated Apps
Enabled:
  - activity: 2.19.0
  - admin_audit: 1.17.0
  - bruteforcesettings: 2.7.0
  - calendar: 4.5.0
  - circles: 27.0.1
  - cloud_federation_api: 1.10.0
  - collectives: 2.7.1
  - comments: 1.17.0
  - contacts: 5.4.0
  - contactsinteraction: 1.8.0
  - dav: 1.27.0
  - deck: 1.11.0
  - drawio: 2.1.2
  - external: 5.2.1
  - federatedfilesharing: 1.17.0
  - federation: 1.17.0
  - files: 1.22.0
  - files_bpm: 1.2.0
  - files_pdfviewer: 2.8.0
  - files_photospheres: 1.27.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - firstrunwizard: 2.16.0
  - keeweb: 0.6.13
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - news: 23.0.0
  - nextcloud_announcements: 1.16.0
  - notes: 4.8.1
  - notifications: 2.15.0
  - notify_push: 0.6.3
  - oauth2: 1.15.1
  - password_policy: 1.17.0
  - photos: 2.3.0
  - previewgenerator: 5.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - richdocuments: 8.1.1
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - support: 1.10.0
  - survey_client: 1.15.0
  - systemtags: 1.17.0
  - tasks: 0.15.0
  - text: 3.8.0
  - theming: 2.2.0
  - theming_customcss: 1.14.0
  - twofactor_backupcodes: 1.16.0
  - twofactor_webauthn: 1.2.0
  - updatenotification: 1.17.0
  - viewer: 2.1.0
  - workflowengine: 2.9.0
Disabled:
  - dashboard: 7.7.0 (installed 7.7.0)
  - encryption: 2.15.0 (installed 2.13.0)
  - files_external: 1.19.0 (installed 1.19.0)
  - recommendations: 1.6.0 (installed 0.4.0)
  - related_resources: 1.2.0 (installed 1.1.0-alpha1)
  - suspicious_login: 5.0.0
  - twofactor_totp: 9.0.0
  - user_ldap: 1.17.0
  - user_status: 1.7.0 (installed 1.5.0)
  - weather_status: 1.7.0 (installed 1.3.0)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs

No response

Additional info

No response

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 in apps/files_versions/lib/Storage.php around the failing get() call shown in the trace, then follow how apps/files_versions/lib/Command/ExpireVersions.php invokes expiration. Reproduce with the listed create, version, delete, and occ versions:expire steps; done means expiration and the corresponding background job complete without an error for deleted files.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.