Occ File Scan Errors - Exception during scan: Unknown error ()

Nextcloud version (eg, 20.0.5): 27.15
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.52
PHP version (eg, 7.4): 8.1.2

The issue you are facing:

Is this the first time you’ve seen this error? Y

Steps to replicate it:

  1. Run:

root@nextcloud:~# sudo -u www-data /usr/bin/php /var/www/nextcloud/occ files:scan --path=“neil/files/Storage”
Starting scan for user 1 out of 1 (neil)
Exception during scan: Unknown error () for Data/Neil/Pictures/Neil’s Images/Royal Victoria Country Park - 240319

  1. That’s it

The output of your Nextcloud log in Admin > Logging:

Nothing gets written to the log

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

<?php
$CONFIG = array (
  'instanceid' => '[sensitive data removed by Mod/JK]',
  'passwordsalt' => '[sensitive data removed by Mod/JK]',
  'secret' => '[sensitive data removed by Mod/JK]',
  'trusted_domains' =>
  array (
    0 => '[sensitive data removed by Mod/JK]',
    1 => '[removed by Mod/JK]',
    2 => '192.168.3.5',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '27.1.5.1',
  'overwrite.cli.url' => '[sensitive data removed by Mod/JK],
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '[sensitive data removed by Mod/JK]',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '[sensitive data removed by Mod/JK]',
  'maintenance' => false,
  'updater.secret' => '[sensitive data removed by Mod/JK]',
  'theme' => '',
  'loglevel' => 2,
);

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

error.log:

[Tue Dec 19 21:52:13.620883 2023] [ssl:warn] [pid 999] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Tue Dec 19 21:52:13.622745 2023] [mpm_prefork:notice] [pid 999] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Tue Dec 19 21:52:13.622752 2023] [core:notice] [pid 999] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 19 22:10:06.347623 2023] [access_compat:error] [pid 1002] [client 192.168.8.7:49753] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Tue Dec 19 22:11:36.856785 2023] [access_compat:error] [pid 1043] [client 192.168.8.7:49862] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata
[Tue Dec 19 22:51:54.575418 2023] [access_compat:error] [pid 2997] [client 192.168.9.1:63075] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata

syslog:

Dec 19 23:05:01 nextcloud CRON[5229]: (root) CMD (sudo -u www-data /usr/bin/php -f /var/www/nextcloud/cron.php > /tmp/nextcloud_cron.log 2>&1)
Dec 19 23:06:01 nextcloud CRON[5284]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:07:01 nextcloud CRON[5347]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:08:01 nextcloud CRON[5408]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:09:00 nextcloud systemd[1]: Starting Clean php session files…
Dec 19 23:09:00 nextcloud systemd[1]: phpsessionclean.service: Deactivated successfully.
Dec 19 23:09:00 nextcloud systemd[1]: Finished Clean php session files.
Dec 19 23:09:01 nextcloud CRON[5542]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:09:01 nextcloud CRON[5544]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Dec 19 23:10:01 nextcloud CRON[5620]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:10:01 nextcloud CRON[5622]: (root) CMD (sudo -u www-data /usr/bin/php -f /var/www/nextcloud/cron.php > /tmp/nextcloud_cron.log 2>&1)
Dec 19 23:11:01 nextcloud CRON[5685]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:12:01 nextcloud CRON[5771]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:13:01 nextcloud CRON[5825]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:14:01 nextcloud CRON[5869]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:15:01 nextcloud CRON[5916]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)
Dec 19 23:15:01 nextcloud CRON[5917]: (root) CMD (sudo -u www-data /usr/bin/php -f /var/www/nextcloud/cron.php > /tmp/nextcloud_cron.log 2>&1)
Dec 19 23:16:01 nextcloud CRON[5976]: (root) CMD (/usr/local/bin/gen_tmplogs.sh > /tmp/gen_tmplogs.cron 2>&1)


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

No idea how to get this information - totally confused as a newbie!

This is the file that is responsible for the problem.
You should examine it carefully. The causes can be varied, for example in the encoding of the name or something like that,
Remove the file and see if the scan runs smoothly.

If you set the Verbose flag (-v) during the scan, you will see exactly which file is currently being processed. This will give you an even closer look at what he stumbles over

Much luck,
ernolf

Hi ernolf,

Thanks for your help. The output from verbose moe isn’t too helpful:

Folder /neil/files/Storage/Data/Neil/Pictures/Neil’s Images/Royal Victoria Country Park - 240319
Exception during scan: Unknown error () for Data/Neil/Pictures/Neil’s Images/Royal Victoria Country Park - 240319
#0 /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php(49): Icewind\SMB\Exception\Exception::unknown()
#1 /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php(92): Icewind\SMB\Exception\Exception::fromMap()
#2 /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php(479): Icewind\SMB\Wrapped\Parser->checkForError()
#3 /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php(178): Icewind\SMB\Wrapped\Share->parseOutput()
#4 /var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php(249): Icewind\SMB\Wrapped\Share->dir()
#5 /var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php(644): OCA\Files_External\Lib\Storage\SMB->getFolderContents()
#6 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/PermissionsMask.php(157): OCA\Files_External\Lib\Storage\SMB->getDirectoryContent()
#7 [internal function]: OC\Files\Storage\Wrapper\PermissionsMask->getDirectoryContent()
#8 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(427): iterator_to_array()
#9 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(397): OC\Files\Cache\Scanner->handleChildren()
#10 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(400): OC\Files\Cache\Scanner->scanChildren()
#11 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(400): OC\Files\Cache\Scanner->scanChildren()
#12 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(400): OC\Files\Cache\Scanner->scanChildren()
#13 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(400): OC\Files\Cache\Scanner->scanChildren()
#14 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(400): OC\Files\Cache\Scanner->scanChildren()
#15 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(347): OC\Files\Cache\Scanner->scanChildren()
#16 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(269): OC\Files\Cache\Scanner->scan()
#17 /var/www/nextcloud/apps/files/lib/Command/Scan.php(164): OC\Files\Utils\Scanner->scan()
#18 /var/www/nextcloud/apps/files/lib/Command/Scan.php(219): OCA\Files\Command\Scan->scanFiles()
#19 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#20 /var/www/nextcloud/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#21 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#22 /var/www/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#23 /var/www/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#24 /var/www/nextcloud/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
#25 /var/www/nextcloud/console.php(100): OC\Console\Application->run()
#26 /var/www/nextcloud/occ(11): require_once(‘…’)
#27 {main}

Any ideas would be much aprpreciated, as it doesn’t appear to show what is wrong with the directory contents.

Many thanks,
Neil

Just a further update - I’ve instaleld php-smbclient and that seems to have fixed my problem. Along with another issue where one of my other scans wasn’t picking up all of the files in a directory.

Definately seems like it’s needed if you’re using extenral storage, which I am.

you posted some sensitive data in your posting. I just removed it… but you should regard your instance as being corrupted…

pls take better care about your own privacy before posting stuff on a public place