There is a folder which I can't delete. Also indexing is broken

Nextcloud version (eg, 20.0.5): 27,0,0,8
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.56-1
PHP version (eg, 7.4): whatever th image uses
I host using docker-compose and the official image.

The issue you are facing:
I have a folder “music” which just causes an error message when trying to delete it. I already cleared the locked files table and restarted my db as well as my nc container while in maintenance mode.
I am running nc hub 4 on debian 11 via a docker stack running rough portainer and the files are stored in a contabo object storage (s3).

I have two accounts.
On both accounts I hav a folder with the same name.
On acc one, the folder is filled. On acc two its empty.
The folder on acc one is alerady shared with acc two.
I tried changing the owner of the folder of acc one to acc two. After accepting the ownership change on acc two, nothing happend.
I tried deleting the still empty folder on acc two. That didnt work
I tried stopping the share on acc one. That didnt work.
I tired opting out of the share on acc two. That worked!
I tried deleting the folder on acc two again with NO success.

I wanted to try to delete the file through occ but I am unsure how that works since the folders are stored in an object storage.

I’ll gladly add any missing info :slight_smile:

PS: A lot of folders across accounts are shown with 0B in them while they are filled with data which is accessible.

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

The output of your Nextcloud log in Admin > Logging:
The Log has like 25k Lines all similar to this one error:

[webdav] Error: TypeError: OC\Files\Cache\QuerySearchHelper::getCachesAndMountPointsForSearch(): Argument #1 ($root) must be of type OC\Files\Node\Root, OC\Files\Node\LazyRoot given, called in /var/www/html/lib/private/Files/Node/Folder.php on line 238 at <<closure>>

 0. /var/www/html/lib/private/Files/Node/Folder.php line 238
    OC\Files\Cache\QuerySearchHelper->getCachesAndMountPointsForSearch(["OC\\Files\\Node\\LazyRoot"], "/tim/files/embyflix", false)
 1. /var/www/html/lib/private/Files/Node/Folder.php line 292
    OC\Files\Node\Folder->search(["OC\\Files\\Search\\SearchQuery"])
 2. /var/www/html/custom_apps/music/lib/Utility/Scanner.php line 383
    OC\Files\Node\Folder->searchByMime("audio")
 3. /var/www/html/custom_apps/music/lib/Hooks/FileHooks.php line 42
    OCA\Music\Utility\Scanner->deleteFolder(["OC\\Files\\Node\\Folder"])
 4. <<closure>>
    OCA\Music\Hooks\FileHooks::deleted(["OC\\Files\\Node\\Folder"])
 5. /var/www/html/lib/private/Hooks/EmitterTrait.php line 105
    call_user_func_array(["OCA\\Music\\Ho ... "], [["OC\\Files\\Node\\Folder"]])
 6. /var/www/html/lib/private/Hooks/PublicEmitter.php line 40
    OC\Hooks\BasicEmitter->emit("\\OC\\Files", "preDelete", [["OC\\Files\\Node\\Folder"]])
 7. /var/www/html/lib/private/Files/Node/Root.php line 143
    OC\Hooks\PublicEmitter->emit("\\OC\\Files", "preDelete", [["OC\\Files\\Node\\Folder"]])
 8. <<closure>>
    OC\Files\Node\Root->emit("\\OC\\Files", "preDelete", [["OC\\Files\\Node\\Folder"]])
 9. /var/www/html/lib/private/Files/Node/LazyFolder.php line 73
    call_user_func_array([["OC\\Files\\Node\\Root"],"emit"], ["\\OC\\Files"," ... ]])
10. /var/www/html/lib/private/Files/Node/LazyFolder.php line 101
    OC\Files\Node\LazyFolder->__call("emit", ["\\OC\\Files"," ... ]])
11. /var/www/html/lib/private/Files/Node/HookConnector.php line 145
    OC\Files\Node\LazyFolder->emit("\\OC\\Files", "preDelete", [["OC\\Files\\Node\\Folder"]])
12. /var/www/html/lib/private/legacy/OC_Hook.php line 105
    OC\Files\Node\HookConnector->delete([true,"/embyflix"])
13. /var/www/html/lib/private/Files/View.php line 1252
    OC_Hook::emit("OC_Filesystem", "delete", [true,"/embyflix"])
14. /var/www/html/lib/private/Files/View.php line 1126
    OC\Files\View->runHooks(["delete"], "/embyflix")
15. /var/www/html/lib/private/Files/View.php line 321
    OC\Files\View->basicOperation("rmdir", "/embyflix", ["delete"])
16. /var/www/html/apps/dav/lib/Connector/Sabre/Directory.php line 307
    OC\Files\View->rmdir("/embyflix")
17. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 179
    OCA\DAV\Connector\Sabre\Directory->delete()
18. /var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 281
    Sabre\DAV\Tree->delete("files/tim/embyflix")
19. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
20. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit("method:DELETE", [["Sabre\\HTTP\\ ... ]])
21. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
22. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
23. /var/www/html/apps/dav/lib/Server.php line 364
    Sabre\DAV\Server->exec()
24. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
25. /var/www/html/remote.php line 172
    require_once("/var/www/html/a ... p")

DELETE /remote.php/dav/files/tim/embyflix
from 89.245.18.211 by tim at 2023-07-13T07:48:34+00:00

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => '<redacted>',
  'passwordsalt' => '<redacted>',
  'secret' => '<redacted>',
  'trusted_domains' => 
  array (
    0 => 'nc.awooo.cc',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'overwrite.cli.url' => '<redacted>',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '<redacted>',
  'installed' => true,
  'objectstore' => 
  array (
    'class' => '\\OC\\Files\\ObjectStore\\S3',
    'arguments' => 
    array (
      'bucket' => 'nextcloud',
      'hostname' => 'eu2.contabostorage.com',
      'key' => '<redacted>',
      'secret' => '<redacted>',
      'port' => 443,
      'use_path_style' => true,
      'use_ssl' => true,
    ),
  ),
  'maintenance' => false,
);

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

Errors are written directly to the /dev/stderr

It could have something to do with this bug: Can’t delete folders while the app is enabled · Issue #1068 · owncloud/music · GitHub

Much luck

Great tip! The app was blocking the directories from being deleted. Now the only problem stays that a lot of other dirs still son’t show their file size.
How can I trigger the calculation of that? Is that something the OCC tool can do?

You can do a rescan of the entire filesystem with

occ files:scan --all

For the details, see the help:

:~# occ files:scan --help
Description:
  rescan filesystem

Usage:
  files:scan [options] [--] [<user_id>...]

Arguments:
  user_id                  will rescan all files of the given user(s)

Options:
      --output[=OUTPUT]    Output format (plain, json or json_pretty, default is plain) [default: "plain"]
  -p, --path=PATH          limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored
      --generate-metadata  Generate metadata for all scanned files
      --all                will rescan all files of all known users
      --unscanned          only scan files which are marked as not fully scanned
      --shallow            do not scan folders recursively
      --home-only          only scan the home storage, ignoring any mounted external storage or share
  -h, --help               Display help for the given command. When no command is given display help for the list command
  -q, --quiet              Do not output any message
  -V, --version            Display this application version
      --ansi|--no-ansi     Force (or disable --no-ansi) ANSI output
  -n, --no-interaction     Do not ask any interactive question
      --no-warnings        Skip global warnings, show command output only
  -v|vv|vvv, --verbose     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

It looks like this doesn’t work. I assume because I use an object storage. But this is the output:

+---------+-------+--------+--------------+
| Folders | Files | Errors | Elapsed time |
+---------+-------+--------+--------------+
| 0       | 0     | 0      | 00:00:00     |
+---------+-------+--------+--------------+