Files:scan -all returns an Exception on one user

Nextcloud version : 17.0.3
Operating system and version : shared host
PHP version : 7.1

The issue you are facing: files:scan --all returns an error

Is this the first time you’ve seen this error? : Y (I recently updated from 16)

Steps to replicate it:

  1. files:scan --all
Starting scan for user 7 out of 10 (USER7)
Exception during scan:
#0 [internal function]: OCA\Files_Sharing\External\Storage->checkStorageAvailability()
#1 /http/0cloud/lib/private/Files/Storage/Wrapper/Wrapper.php(506): call_user_func_array(Array, Array)
#2 [internal function]: OC\Files\Storage\Wrapper\Wrapper->__call('checkStorageAva...', Array)
#3 /http/0cloud/lib/private/Files/Storage/Wrapper/Wrapper.php(506): call_user_func_array(Array, Array)
#4 /http/0cloud/apps/files_sharing/lib/External/Scanner.php(89): OC\Files\Storage\Wrapper\Wrapper->__call('checkStorageAva...', Array)
#5 /http/0cloud/apps/files_sharing/lib/External/Scanner.php(44): OCA\Files_Sharing\External\Scanner->scanAll()
#6 /http/0cloud/lib/private/Files/Utils/Scanner.php(245): OCA\Files_Sharing\External\Scanner->scan('', true, 3)
#7 /http/0cloud/apps/files/lib/Command/Scan.php(145): OC\Files\Utils\Scanner->scan('/michel', true, NULL)
#8 /http/0cloud/apps/files/lib/Command/Scan.php(201): OCA\Files\Command\Scan->scanFiles('michel', '/michel', Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#9 /http/0cloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /http/0cloud/core/Command/Base.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /http/0cloud/3rdparty/symfony/console/Application.php(908): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /http/0cloud/3rdparty/symfony/console/Application.php(269): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /http/0cloud/3rdparty/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /http/0cloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /http/0cloud/console.php(97): OC\Console\Application->run()
#16 /http/0cloud/occ(11): require_once('/http/0cloud/co...')
#17 {main}
Starting scan for user 8 out of 10 (USER8)

The output of your Nextcloud log in Admin > Logging:

[PHP] Error: Invalid argument supplied for foreach() at /http/cloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#120

GET /settings/admin/serverinfo
from by USER7 at 2020-04-08T17:08:21+02:00

Please try to use occ filecan withj the --path option to narrow down which file of the user causes the problem. I have in mind that e.g. the scan function could fail, if a file name contains two plus signs in a row. As soon as you’ve identified the file, a possible solution would be to rename it.

How do I have to set up the Path correctly? there is no example in the scan:files 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
      --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 this help message
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi             Force ANSI output
      --no-ansi          Disable 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 seems I took an unnecessary detour :rofl:

That was so fucking tedious to hunt down the problem. At the end it is a shared nextcloud, in that nextcloud with a bunch of files there was a file with a , in his file name. I temporary renamed this file and replaced the comma with a - and after that files:Scan work.

It’s strange If I create this file with this name into another directory this problem seems not appear. If I rename the original again back the problem appear again.

1 Like

More strange It seems that Directory[n]/subdirectory[n]/filename.pdf are named by a rule so there is a bunch of files which are named similar but has an only difference in a number.

That’s interesting. I think it is worse to identify the rule which generates the files and fix it. As usual there characters which shouldn’t be part of file names as discussed here:

I requested the admin of the shared nextcloud to do a files:scan -all. He do not get any exceptions. But I still have it if I do files:scan --path=xxx on the shared folder where this file lay.