Error OCP\Files\NotPermitted Exception occurs every 15 minutes

Hi guys,

I have NC (22.1.1) as a docker container on my unraid server, as a database I have the latest version of mariadb running.

Every 15 minutes I get the error message in the annex. Unfortunately I don’t know what to do with this, so I would like to know, if someone can help me with this.

In the logs of both docker container no errors occur. A restart of the container also does not solve the problem.

Thank you very much for your help!

Maginos

Bildschirmfoto 2021-09-20 um 21.58.54

PS: here’s the error message in plain text:

{“reqId”:“wC4kx86r8GzIkQQhyhVs”,“level”:3,“time”:“2021-09-20T20:20:01+00:00”,“remoteAddr”:"",“user”:"–",“app”:“files”,“method”:"",“url”:"–",“message”:"",“userAgent”:"–",“version”:“22.1.1.2”,“exception”:{“Exception”:“OCP\Files\NotPermittedException”,“Message”:"",“Code”:0,“Trace”:[{“file”:"/config/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php",“line”:623,“function”:“getFolderContents”,“class”:“OCA\Files_External\Lib\Storage\SMB”,“type”:"->"},{“function”:“getDirectoryContent”,“class”:“OCA\Files_External\Lib\Storage\SMB”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:408,“function”:“iterator_to_array”},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:388,“function”:“handleChildren”,“class”:“OC\Files\Cache\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:340,“function”:“scanChildren”,“class”:“OC\Files\Cache\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:510,“function”:“scan”,“class”:“OC\Files\Cache\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:521,“function”:“OC\Files\Cache\{closure}”,“class”:“OC\Files\Cache\Scanner”,“type”:"->",“args”:["*** sensitive parameters replaced ***"]},{“file”:"/config/www/nextcloud/lib/private/Files/Cache/Scanner.php",“line”:509,“function”:“runBackgroundScanJob”,“class”:“OC\Files\Cache\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/Files/Utils/Scanner.php",“line”:185,“function”:“backgroundScan”,“class”:“OC\Files\Cache\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",“line”:89,“function”:“backgroundScan”,“class”:“OC\Files\Utils\Scanner”,“type”:"->"},{“file”:"/config/www/nextcloud/apps/files/lib/BackgroundJob/ScanFiles.php",“line”:125,“function”:“runScanner”,“class”:“OCA\Files\BackgroundJob\ScanFiles”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/BackgroundJob/Job.php",“line”:51,“function”:“run”,“class”:“OCA\Files\BackgroundJob\ScanFiles”,“type”:"->"},{“file”:"/config/www/nextcloud/lib/private/BackgroundJob/TimedJob.php",“line”:58,“function”:“execute”,“class”:“OC\BackgroundJob\Job”,“type”:"->"},{“file”:"/config/www/nextcloud/cron.php",“line”:127,“function”:“execute”,“class”:“OC\BackgroundJob\TimedJob”,“type”:"->"}],“File”:"/config/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php",“Line”:242,“CustomMessage”:"–"},“id”:“6148ecf1cfae2”}

1 Like

NotPermittedException sounds like there is some file access problem. The mentions of files_external and SMB point to a problem with a file on external storage, namely a SAMBA share (same as windows file share). You probably need to check file access permissions for all files and folders in external SAMBA shares that you have added to nextcloud.

Since I have all my data (videos, music, photos, etc.) on SMB shares, that could be a bit problematic to find exactly what causes this error. Do you know how I can investigate, which file/folder causes this issue? Are there other log files which could help?

Unfortunately I don’t know a direct way of knowing which file is the cause.
What you could do however is do a recursive application of file permissions; under linux, for example, with the chmod command; to make all files and folders readable to the owner group, you’d need to execute chmod -R g+r . in the respective directory. (Note: in case you’re not familiar with Linux file permissions yet - for the folders also the “execute” permission needs to be set to be able to access it; to set this for all (recursive) subfolders in the current folder, use find . -type d -exec chmod g+x {} \; (including the \; at the end). If for some reason you need to set read permissions for all, use a instead of g in front of the +r/+x.

Via Facebook I also got the tip to execute the two following commands in the docker container:

find htmlpath -type d -exec chmod 755 {} ;
find htmlpath -type f -exec chmod 644 {} ;

As htmlpath I used /config/www/ and also /data/www/. All commands passed without any output, after a restart of the docker container I still get the error message.

What are the /config/www and /data/www folders? Are those the folders included in your nextclou via SMB?

You need to execute those commands on the folders that you are including via SMB.

I did and it didn’t help unfortunately.

BUT: When I open one of my SMB folders in the WebGUI, it says “files can not be loaded. Please check your internet connection”. When I then navigate in the docker shell to the folder, I can see, that not all folders are present that should be there. So there seems to be a problem with this folder. Executing the two commands in this folder doesn’t help.

There could also be something wrong with the permissions on the SMB level, or some other access control mechanism could be interfering…

Can you access all folders when you access the share via your file manager?

Ok, hopefully not…

Yes, I don’t have any problems with that.

@codeling : When I execute “occ files:scan -all” many files with German Umlaute are detected and the error message looks like this:

“Entry filename will not be accessible due to incompatible encoding”

Could that be the problem?

Unfortunately I don’t really know, but it sounds plausible that this could cause such issues!

There seems to be a solution:

https://help.nextcloud.com/t/will-not-be-accessible-due-to-incompatible-encoding/86612

So I have to install convmv, in the Docker image or on Unraid?

I found a solution for this problem, here it is:

  1. Install the nerdpack on unraid
  2. Within nerdpack, install convmv
  3. Go to unraid console (not nextcloud) and run
convmv -f utf-8 -t utf-8 -r --notest --nfc <nextcloud-data-folder>

against all folders, that are mounted in NC. So the command could be something like:

convmv -f utf-8 -t utf-8 -r --notest --nfc /mnt/user/home_maginos/

To determine specifically, which folders you have to run the convmv command against, you should have a look at the output of the occ files:scan --all command within the nextcloud docker console. OCC is enabled by running sudo -u abc php /config/www/nextcloud/occ. After occ files:scan --all has finished, there is a list of files with “incompatible encoding”. To the location of these files, the convmv command must be run against.