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
 2. /var/www/html/custom_apps/music/lib/Utility/Scanner.php line 383
 3. /var/www/html/custom_apps/music/lib/Hooks/FileHooks.php line 42
 4. <<closure>>
 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
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
17. /var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php line 179
18. /var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 281
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
23. /var/www/html/apps/dav/lib/Server.php line 364
24. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
25. /var/www/html/remote.php line 172
    require_once("/var/www/html/a ... p")

DELETE /remote.php/dav/files/tim/embyflix
from 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!):

$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 => '',
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '',
  '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' => '',
      '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
  rescan filesystem

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

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

      --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     |