Nextcloud 26.0.1 - Folder size inaccurate after deleting a bulk of files

Nextcloud version (eg, 20.0.5): 26.0.1
Operating system and version (eg, Ubuntu 20.04): Debian 10 (Buster)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.38
PHP version (eg, 7.4): 8.0.28

The issue you are facing:

I am backing up settings and chats of my apps on my Android phone to my Nextcloud. To do this, I have setup “Auto Uploads” in the Nextcloud app to automatically upload once there is a new file.

The folder for my Chats quickly fills after a few days due to a daily backup. When I go ahead an do a bulk delete of the old backups, it deletes the files but after some the folder size is getting stuck and stays at a random amount.

At first I encountered this issue while I had the file deletion automated via the Nextcloud retention app. I deactivated the retention app and tried again to see if it was the app causing it, but the same happened after a while even without the app.

The only way I can work around this at the moment is by renaming the folders in question, creating new folders with the original names, moving the files to the new folder and then deleting the old/original folder.

Example:

Android Backups → Signal (Original)

Rename Signal folder:
Android Backups -> Signal-bak

Create new Signal folder and move the existing files from Signal-bak to Signal

Rename Android Backups folder
Android Backups-bak

Create new Android Backups folder and move the existing folders/files from Android Backups-bak to Android Backups

Is this the first time you’ve seen this error? (Y/N): No

Steps to replicate it:

I was unable to find a way to reproduce this issue reliably. I can only say that it might be connected to bulk deleting files and Nextcloud getting confused?!

The output of your Nextcloud log in Admin > Logging: (There is only a bunch of the following entries in my logs, nothing else)

{
	"reqId": "ZGfjD-kK37OWG@bElQPnZAAAAFI",
	"level": 3,
	"time": "2023-05-19T20:58:55+00:00",
	"remoteAddr": "***",
	"user": "--",
	"app": "no app in context",
	"method": "GET",
	"url": "/",
	"message": "App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8d0ed5e4.publicKey existing mounts: ",
	"userAgent": "--",
	"version": "26.0.1.1",
	"exception": {
		"Exception": "OCP\\Files\\NotFoundException",
		"Message": "No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8d0ed5e4.publicKey existing mounts: ",
		"Code": 0,
		"Trace": [
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Filesystem.php",
				"line": 319,
				"function": "find",
				"class": "OC\\Files\\Mount\\Manager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/View.php",
				"line": 1167,
				"function": "resolvePath",
				"class": "OC\\Files\\Filesystem",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/View.php",
				"line": 548,
				"function": "basicOperation",
				"class": "OC\\Files\\View",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Encryption/Keys/Storage.php",
				"line": 268,
				"function": "file_exists",
				"class": "OC\\Files\\View",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Encryption/Keys/Storage.php",
				"line": 228,
				"function": "getKey",
				"class": "OC\\Encryption\\Keys\\Storage",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Encryption/Keys/Storage.php",
				"line": 120,
				"function": "getKeyWithUid",
				"class": "OC\\Encryption\\Keys\\Storage",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/apps/encryption/lib/KeyManager.php",
				"line": 614,
				"function": "getSystemUserKey",
				"class": "OC\\Encryption\\Keys\\Storage",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/apps/encryption/lib/KeyManager.php",
				"line": 170,
				"function": "getPublicShareKey",
				"class": "OCA\\Encryption\\KeyManager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/apps/encryption/lib/Users/Setup.php",
				"line": 62,
				"function": "validateShareKey",
				"class": "OCA\\Encryption\\KeyManager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/apps/encryption/lib/AppInfo/Application.php",
				"line": 55,
				"function": "setupSystem",
				"class": "OCA\\Encryption\\Users\\Setup",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/apps/encryption/appinfo/app.php",
				"line": 37,
				"function": "setUp",
				"class": "OCA\\Encryption\\AppInfo\\Application",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/legacy/OC_App.php",
				"line": 316,
				"args": [
					"/var/www/vhosts/my-host/my-nextcloud/apps/encryption/appinfo/app.php"
				],
				"function": "require_once"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/legacy/OC_App.php",
				"line": 192,
				"function": "requireAppFile",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/legacy/OC_App.php",
				"line": 141,
				"function": "loadApp",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/SetupManager.php",
				"line": 132,
				"function": "loadApps",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/SetupManager.php",
				"line": 351,
				"function": "setupBuiltinWrappers",
				"class": "OC\\Files\\SetupManager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/SetupManager.php",
				"line": 391,
				"function": "setupRoot",
				"class": "OC\\Files\\SetupManager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Mount/Manager.php",
				"line": 95,
				"function": "setupForPath",
				"class": "OC\\Files\\SetupManager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/View.php",
				"line": 1390,
				"function": "find",
				"class": "OC\\Files\\Mount\\Manager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Node/Root.php",
				"line": 205,
				"function": "getFileInfo",
				"class": "OC\\Files\\View",
				"type": "->"
			},
			{
				"function": "get",
				"class": "OC\\Files\\Node\\Root",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Node/LazyFolder.php",
				"line": 72,
				"function": "call_user_func_array"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Node/LazyFolder.php",
				"line": 149,
				"function": "__call",
				"class": "OC\\Files\\Node\\LazyFolder",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/AppData/AppData.php",
				"line": 132,
				"function": "get",
				"class": "OC\\Files\\Node\\LazyFolder",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Template/JSCombiner.php",
				"line": 87,
				"function": "getFolder",
				"class": "OC\\Files\\AppData\\AppData",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Template/JSResourceLocator.php",
				"line": 120,
				"function": "process",
				"class": "OC\\Template\\JSCombiner",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Template/JSResourceLocator.php",
				"line": 72,
				"function": "cacheAndAppendCombineJsonIfExist",
				"class": "OC\\Template\\JSResourceLocator",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Template/ResourceLocator.php",
				"line": 73,
				"function": "doFind",
				"class": "OC\\Template\\JSResourceLocator",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/TemplateLayout.php",
				"line": 377,
				"function": "find",
				"class": "OC\\Template\\ResourceLocator",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/TemplateLayout.php",
				"line": 222,
				"function": "findJavascriptFiles",
				"class": "OC\\TemplateLayout",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/legacy/OC_Template.php",
				"line": 182,
				"function": "__construct",
				"class": "OC\\TemplateLayout",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Template/Base.php",
				"line": 132,
				"function": "fetchPage",
				"class": "OC_Template",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/base.php",
				"line": 833,
				"function": "printPage",
				"class": "OC\\Template\\Base",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/lib/base.php",
				"line": 1165,
				"function": "init",
				"class": "OC",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/my-host/my-nextcloud/index.php",
				"line": 34,
				"args": [
					"/var/www/vhosts/my-host/my-nextcloud/lib/base.php"
				],
				"function": "require_once"
			}
		],
		"File": "/var/www/vhosts/my-host/my-nextcloud/lib/private/Files/Mount/Manager.php",
		"Line": 118,
		"message": "App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8d0ed5e4.publicKey existing mounts: ",
		"CustomMessage": "App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8d0ed5e4.publicKey existing mounts: "
	}
}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "my-nextcloud"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "26.0.1.1",
        "overwrite.cli.url": "https:\/\/my-nextcloud\/",
        "htaccess.RewriteBase": "\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "simpleSignUpLink.shown": false,
        "default_phone_region": "DE",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "loglevel": 2,
        "maintenance": false
    },
    "apps": {
        "activity": {
            "enable_email": "no",
            "enabled": "yes",
            "installed_version": "2.18.0",
            "notify_email_calendar": "0",
            "notify_email_calendar_event": "0",
            "notify_email_calendar_todo": "0",
            "notify_email_contacts": "0",
            "notify_email_file_changed": "0",
            "notify_email_group_settings": "0",
            "notify_notification_calendar": "0",
            "notify_notification_calendar_event": "0",
            "notify_notification_calendar_todo": "0",
            "notify_notification_contacts": "0",
            "notify_notification_favorite": "0",
            "notify_notification_file_changed": "0",
            "notify_notification_file_favorite_changed": "0",
            "notify_notification_group_settings": "0",
            "notify_notification_personal_settings": "0",
            "notify_notification_security": "1",
            "notify_setting_batchtime": "3600",
            "notify_setting_self": "0",
            "notify_setting_selfemail": "0",
            "types": "filesystem"
        },
        "admin_audit": {
            "enabled": "yes",
            "installed_version": "1.16.0",
            "types": "logging"
        },
        "backgroundjob": {
            "lastjob": "13"
        },
        "breezedark": {
            "enabled": "no",
            "installed_version": "24.0.2",
            "theme_automatic_activation_enabled": "1",
            "theme_cachebuster": "0",
            "theme_custom_styling": "",
            "theme_enabled": "1",
            "theme_login_page": "1",
            "types": ""
        },
        "circles": {
            "enabled": "no",
            "installed_version": "24.0.0",
            "loopback_tmp_scheme": "https",
            "maintenance_run": "0",
            "maintenance_update": "{\"3\":1658354970,\"2\":1658354970,\"1\":1658354971}",
            "types": "filesystem,dav"
        },
        "cloud_federation_api": {
            "enabled": "yes",
            "installed_version": "1.9.0",
            "types": "filesystem"
        },
        "comments": {
            "enabled": "no",
            "installed_version": "1.14.0",
            "types": "logging"
        },
        "contactsinteraction": {
            "enabled": "no",
            "installed_version": "1.5.0",
            "types": "dav"
        },
        "core": {
            "backgroundjobs_mode": "cron",
            "default_encryption_module": "OC_DEFAULT_MODULE",
            "emailTestSuccessful": "1",
            "encryption_enabled": "yes",
            "installedat": "1658352012.8921",
            "lastcron": "1684927210",
            "lastupdateResult": "[]",
            "lastupdatedat": "1684925301",
            "moveavatarsdone": "yes",
            "oc.integritycheck.checker": "[]",
            "previewsCleanedUp": "1",
            "public_files": "files_sharing\/public.php",
            "public_webdav": "dav\/appinfo\/v1\/publicwebdav.php",
            "theming.variables": "41545bc493ea402b7a9b19b640ab406b",
            "updater.secret.created": "1682349211",
            "vendor": "nextcloud"
        },
        "dashboard": {
            "enabled": "no",
            "installed_version": "7.4.0",
            "types": ""
        },
        "dav": {
            "buildCalendarReminderIndex": "yes",
            "buildCalendarSearchIndex": "yes",
            "chunks_migrated": "1",
            "enabled": "yes",
            "generateBirthdayCalendar": "no",
            "installed_version": "1.25.0",
            "regeneratedBirthdayCalendarsForYearFix": "yes",
            "sendEventReminders": "no",
            "sendInvitations": "no",
            "types": "filesystem"
        },
        "encryption": {
            "enabled": "yes",
            "installed_version": "2.14.0",
            "masterKeyId": "master_8d0ed5e4",
            "publicShareKeyId": "pubShare_8d0ed5e4",
            "recoveryKeyId": "recoveryKey_8d0ed5e4",
            "types": "filesystem"
        },
        "federatedfilesharing": {
            "enabled": "yes",
            "installed_version": "1.16.0",
            "types": ""
        },
        "federation": {
            "enabled": "no",
            "installed_version": "1.14.0",
            "types": "authentication"
        },
        "files": {
            "enabled": "yes",
            "installed_version": "1.21.1",
            "types": "filesystem"
        },
        "files_automatedtagging": {
            "enabled": "no",
            "installed_version": "1.15.3",
            "types": "filesystem"
        },
        "files_pdfviewer": {
            "enabled": "yes",
            "installed_version": "2.7.0",
            "types": ""
        },
        "files_retention": {
            "enabled": "no",
            "installed_version": "1.14.1",
            "notify_before": "no",
            "types": ""
        },
        "files_rightclick": {
            "enabled": "yes",
            "installed_version": "1.5.0",
            "types": ""
        },
        "files_sharing": {
            "enabled": "no",
            "incoming_server2server_share_enabled": "no",
            "installed_version": "1.16.2",
            "lookupServerEnabled": "no",
            "lookupServerUploadEnabled": "no",
            "outgoing_server2server_share_enabled": "no",
            "types": "filesystem"
        },
        "files_trashbin": {
            "enabled": "yes",
            "installed_version": "1.16.0",
            "types": "filesystem,dav"
        },
        "files_versions": {
            "enabled": "no",
            "installed_version": "1.18.0",
            "types": "filesystem,dav"
        },
        "firstrunwizard": {
            "enabled": "no",
            "installed_version": "2.13.0",
            "types": "logging"
        },
        "logreader": {
            "enabled": "yes",
            "installed_version": "2.11.0",
            "types": ""
        },
        "lookup_server_connector": {
            "enabled": "yes",
            "installed_version": "1.14.0",
            "types": "authentication"
        },
        "nextcloud_announcements": {
            "enabled": "no",
            "installed_version": "1.13.0",
            "pub_date": "Thu, 24 Oct 2019 00:00:00 +0200",
            "types": "logging"
        },
        "notifications": {
            "enabled": "yes",
            "installed_version": "2.14.0",
            "types": "logging"
        },
        "oauth2": {
            "enabled": "yes",
            "installed_version": "1.14.0",
            "types": "authentication"
        },
        "password_policy": {
            "enabled": "yes",
            "enforceNumericCharacters": "1",
            "enforceSpecialCharacters": "1",
            "enforceUpperLowerCase": "1",
            "installed_version": "1.16.0",
            "types": "authentication"
        },
        "photos": {
            "enabled": "yes",
            "installed_version": "2.2.0",
            "lastPlaceMappedUser": "user1",
            "lastPlaceMappingDone": "true",
            "types": "dav,authentication"
        },
        "previewgenerator": {
            "enabled": "no",
            "installed_version": "5.1.1",
            "types": "filesystem"
        },
        "privacy": {
            "enabled": "no",
            "installed_version": "1.8.0",
            "types": ""
        },
        "provisioning_api": {
            "enabled": "yes",
            "installed_version": "1.16.0",
            "types": "prevent_group_restriction"
        },
        "recommendations": {
            "enabled": "no",
            "installed_version": "1.3.0",
            "types": ""
        },
        "related_resources": {
            "enabled": "yes",
            "installed_version": "1.1.0-alpha1",
            "types": ""
        },
        "serverinfo": {
            "cached_count_filecache": "14305",
            "cached_count_storages": "3",
            "enabled": "yes",
            "installed_version": "1.16.0",
            "types": ""
        },
        "settings": {
            "enabled": "yes",
            "installed_version": "1.8.0",
            "profile_enabled_by_default": "0",
            "types": ""
        },
        "sharebymail": {
            "enabled": "no",
            "installed_version": "1.14.0",
            "types": "filesystem"
        },
        "support": {
            "enabled": "no",
            "installed_version": "1.7.0",
            "types": "session"
        },
        "survey_client": {
            "enabled": "no",
            "installed_version": "1.12.0",
            "types": ""
        },
        "systemtags": {
            "enabled": "no",
            "installed_version": "1.15.0",
            "types": "logging"
        },
        "text": {
            "enabled": "yes",
            "installed_version": "3.7.2",
            "types": "dav"
        },
        "theming": {
            "cachebuster": "2",
            "enabled": "yes",
            "installed_version": "2.1.1",
            "slogan": "***REMOVED SENSITIVE VALUE***",
            "types": "logging",
            "url": "***REMOVED SENSITIVE VALUE***"
        },
        "twofactor_backupcodes": {
            "enabled": "yes",
            "installed_version": "1.15.0",
            "types": ""
        },
        "twofactor_totp": {
            "enabled": "yes",
            "installed_version": "8.0.0-alpha.0",
            "types": ""
        },
        "updatenotification": {
            "breezedark": "24.0.2",
            "core": "25.0.6.1",
            "enabled": "yes",
            "files_automatedtagging": "1.15.3",
            "installed_version": "1.16.0",
            "related_resources": "1.0.4",
            "twofactor_totp": "6.4.1",
            "types": "",
            "update_check_errors": "0"
        },
        "user_status": {
            "enabled": "no",
            "installed_version": "1.4.0",
            "types": ""
        },
        "viewer": {
            "enabled": "yes",
            "installed_version": "1.10.0",
            "types": ""
        },
        "weather_status": {
            "enabled": "no",
            "installed_version": "1.4.0",
            "types": ""
        },
        "workflowengine": {
            "enabled": "yes",
            "installed_version": "2.8.0",
            "types": "filesystem"
        }
    }
}

The output of your Apache/nginx/system log in /var/log/____:

Those are empty

How much storage are we talking about here?

When you say it’s staying at a “random” amount are you saying it isn’t getting stuck at the pre-deletion number, but some (seemingly) uncorrelated to anything number?

Also, are you checking from your Android phone? What does the Web interface amount say? Does it make a difference if you do the bulk delete in the web interface?

Are you by chance hosting this on a 32 bit platform?

I see you’re using encryption. You may be able to address those errors:

https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#troubleshooting-downloading-or-decrypting-files

The last time I checked the folder, it was showing around 3.2 GB - I then selected all but one file and clicked on delete. It deleted all files but the one I did not select. This file has a size of 182.40 MB the folder however shows a size of 1.9 GB

I checked via the phone app as well as the web interface. Both show the same wrong size. I also tried the deletion via the app and the web interface and both create this issue at some point. As mentioned before the annoying thing is that I can’t reliably reproduce this problem to really pinpoint what is causing it.

Thinking back, I believe this started with version 25 of Nextcloud.

Negative, the system is a 64 bit platform. I also already downloaded all my data on a weekend and tried completely reinstalling Nextcloud but that didn’t help.

I will have a look at the troubleshooting link tomorrow. But why all of a sudden should the install have encryption problems? Sounds odd to me

I have had a look at the link and saw the occ files:scan - This was the first thing I came across when searching around for a solution. I did execute this command in the past but it had no effect.

The instance is encrypted since the installation (before any files had been uploaded). The encryption has never been disabled since.

Seeing the SQL statement in the above link, I went ahead and did some research on the database.

I selected every row where encrypted = 0 and unencrypted_size != 0

SELECT *
FROM oc_filecache
WHERE encrypted = 0
AND unencrypted_size != 0;

It listed three entries, where two of them were assigned to my storage ID. These two entries looked unfamiliar to me. One referred to a folder called upload that never existed in my instance and the other one was unnamed. I backed up the database, deleted these two entries and ran the file:scan again.

I will monitor now whether this fixed it or not and will report back