Running user:delete on accounts no longer removes their files

Nextcloud 22.1.1
Ubuntu 20.04.2
Apache 2.4.41
PHP 7.4.3

Local storage

Doing some ldap remnant cleanup with occ user:delete since updating to nextcloud 22. Files are not deleted from storage, and the deleted users’ storages and files still show up in the database tables _storages and _filecache

users are deleted from _accounts and are no longer listed in occ ldap:show-remnants

I tested the same using a non-ldap account created with user:add and see the same problem.
Here’s the debug log output for that attempt

{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"files_antivirus","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"extract","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"files_sharing","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"metadata","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"suspicious_login","method":"","url":"--","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::preDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::changeUser: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for a changed card in addressbook 1","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCA\\DAV\\CardDAV\\CardDavBackend::updateCard: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"onlyoffice","method":"","url":"--","message":"deleteAllVersions dummytest ","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::preDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::changeUser: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for OCP\\IUser::postDelete: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for a deleted card in addressbook 1","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":1,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCA\\DAV\\CardDAV\\CardDavBackend::deleteCard: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for deleted calendar 160","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Reminders of calendar 160 cleaned up","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Default calendar needs no update because the deleted calendar is no the user's default one","userAgent":"--","version":"22.1.1.2"}
{"reqId":"yrHKutLTIa8a526cTNiX","level":0,"time":"2021-09-09T21:28:35+00:00","remoteAddr":"","user":"--","app":"dav","method":"","url":"--","message":"Activity generated for deleted addressbook 158","userAgent":"--","version":"22.1.1.2"}

I’m guessing something broke when the code below was removed from /lib/private/User/User.php in favor of the functions in the event catcher added at lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php

			// Delete user files in /data/
			if ($homePath !== false) {
				// FIXME: this operates directly on FS, should use View instead...
				// also this is not testable/mockable...
				\OC_Helper::rmdirr($homePath);
			}

			// Delete the users entry in the storage table
			Storage::remove('home::' . $this->uid);

I manually undid this change by putting back the lines that were removed in the commit and now everything is being removed as before. But obviously this isn’t an ideal solution going forward.

1 Like