Occ file:scan --all, numerous cannot stat no such file or directory errors

Nextcloud version (eg, 20.0.5): 21
Operating system and version (eg, Ubuntu 20.04): Raspbian GNU/Linux 10 (buster)
Apache or nginx version (eg, Apache 2.4.25): nginx/1.14.2
PHP version (eg, 7.4): v8.0.3

I run a file scan nightly in cron to keep my nextcloud server optimized. I did a manual scan today and noticed something very strange which I’ve never seen before.

I run this command from cli:
sudo -u www-data php /var/www/nextcloud/occ files:scan --all

And am getting a lot of errors:
stat: cannot stat ‘/path/to/file’: No such file or directory

I checked on the web interface and the file exists. I also checked the path via cli on the server itself and verified it exists. File and folder permissions look ok.

Any ideas or help troubleshooting would be greatly appreciated. Thank you!

Please provide an example of such a file and run the following commands on the console:

sudo -u www-data ls -ald /path
sudo -u www-data ls -ald /path/to
sudo -u www-data ls -ald /path/to/file
...
sudo -u www-data stat /path/to/file
1 Like

Example:
stat: cannot stat ‘/path/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’: No such file or directory

First 2 commands succeed:
sudo -u www-data ls -ald ‘/path/ncdatadir/user/files/Events/2018/10 E-Oct’
sudo -u www-data ls -ald ‘/path/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris’

This one fails with: ls: cannot access
sudo -u www-data ls -ald ‘/path/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’

This also fails with: stat: cannot stat
sudo -u www-data stat ‘/path/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’

Yet I can see and access the file in the nextcloud web interface just fine.

Ok, it seems that we’re on the right track. Please execute the commands again but this time please also provide the EXACT output of each command.

Here is the EXACT output of the commands:

$ sudo -u www-data ls -ald /var/ncdatadir/user/files/Events/2018/
drwxr-xr-x 15 www-data www-data 4096 Oct 18 2018 /var/ncdatadir/user/files/Events/2018/

$ sudo -u www-data ls -ald ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct’
drwxr-xr-x 53 www-data www-data 4096 Oct 30 2018 ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct’

$ sudo -u www-data ls -ald ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’
ls: cannot access ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’: No such file or directory

$ sudo -u www-data stat ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’
stat: cannot stat ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris/San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg’: No such file or directory

Am I right that “3 Tech talk @ Harris/San_Francisco,*CA__TechTalk_Summits*-_2018-10-01_09.05.46.jpg” is the file name of the jpg-file you’re trying to access?

If so, I see two problems with the file naming which are most likely causing the problems:

  1. The character “*” is used in the file name which is by default the wildcard character on most OSes, so that I would recommend not to use it at all.
  2. The character “/” is used in the file name which is by default the directory separator on Linux, so that I would recommend not to use it at all.

To solve the problem I would recommend to rename the file and get rid of the given characters.

No. This is the file name I’m trying to access:
San_Francisco,CA__TechTalk_Summits-_2018-10-01_09.05.46.jpg

It is named properly and has no * or / in it.

Ok, in this case you’ve jumped over at least one directory as you checked the access rights. What is thje result of the following command:

$ sudo -u www-data ls -ald ‘/var/ncdatadir/user/files/Events/2018/10 E-Oct/3 Tech talk @ Harris'

sudo -u www-data ls -ald ‘/var/ncdatadir/user/Events/2018/10 E-Oct/3 Tech talk @ Harris’
drwxr-xr-x 2 www-data www-data 4096 Oct 1 2018 ‘/var/nc_data/ed/files/Events/2018/10 E-Oct/3 Tech talk @ Harris’