ownCloud Server 9.1.4 - You don't have permission to upload or create files here

Steps to reproduce

I do not know how to reproduce the issue yet. I started to sync a large set of files (25 GB) for a new user. There were a .gitignore file in one of the folders, which I deleted, because I read that there are open issues regarding those files.

Expected behaviour
Files and folders shouldn't be write protected.
The size of files and folder should be shown in the client and in the web view.

Actual behaviour
I deleted an old installation of owncloud and let the user upload his files again to my new installation. After that the logfile suddenly was full of error messages (see in section for logs below).

Now most of my synced files are write protected.
On the web view the following message is shown to me in all folders (even root):

"You don't have permission to upload or create files here"

Additionally on the client side all folders are shown with size 0 in the sync client. On the server side the size of the folders is "pending...".

On the client the chmod settings look like that:

r--r--r-- 1 user group 24086 Jul 16 2011 #Briefvorlage.odt
-r--r--r-- 1 user group 34735 Apr 16 2011 #Briefvorlage.ott
-r--r--r-- 1 user group 86413 Jul 16 2011 #Briefvorlage.pdf

On the server the chmod settings seem to be normal:

-rw-r-----+ 1 www-data www-data 24K Jul 16 2011 #Briefvorlage.odt
-rw-r-----+ 1 www-data www-data 34K Apr 16 2011 #Briefvorlage.ott
-rw-r-----+ 1 www-data www-data 85K Jul 16 2011 #Briefvorlage.pdf

I already used the script provided in the admin manual to ensure the permissions on the server are ok: https://doc.owncloud.org/server/latest/admin_manual/installation/installation_wizard.html?highlight=chmod#strong-perms-label.

The cron job is started by operating system cron and has the green status (last job execution 8 minutes ago).

I tried the scan:files command, but it had no effect:

sudo -u www-data php occ files:scan --all
Scanning files for 4 users
Starting scan for user 1 out of 4 (admin)
Starting scan for user 2 out of 4 (user1)
Starting scan for user 3 out of 4 (user2)
Starting scan for user 4 out of 4 (user3)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 2098    | 28726 | 00:01:14     |
+---------+-------+--------------+

Does someone have any suggestions what I can do?

Server configuration
Operating system: Debian 7 Wheezy
Web server: Apache2
Database: Mysql 5.6.35
PHP version: PHP 5.4.45-0+deb7u7
ownCloud version (see ownCloud admin page): 9.1.4
Updated from an older ownCloud or fresh install: Updated from 9.1.3 some weeks ago, but the problem is new:
term.log:Preparing to replace owncloud-files 9.1.3-1.1 (using .../owncloud-files_9.1.4-1.1_all.deb)

Special configuration (external storage, external authentication, reverse proxy, server-side-encryption):
default configuration

ownCloud log (data/owncloud.log)

{"reqId":"huaaNHkoT5BM0bJAXau3","remoteAddr":"my.ip.address","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\\/1.1 400 expected filesize 4525738 got 0\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\BadRequest\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Directory.php(136): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->put(Resource id #414)\\n#1 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1036): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Directory->createFile('file.name', Resource id #414)\\n#2 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(523): Sabre\\\\DAV\\\\Server->createFile('path/to/file', Resource id #414, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(459): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#6 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(248): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(57): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/var\\\/www\\\/owncloud\\\/remote.php(164): require_once('\\\/var\\\/www\\\/ownclo...')\\n#9 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":149,\"User\":\"username\"}","level":4,"time":"2017-02-27T08:15:10+00:00","method":"PUT","url":"\/owncloud9\/remote.php\/webdav\/path/to/a/file","user":"username"}

Integrity status for oC9+

No errors have been found.

Does this only happen to files with special characters (#)?

Did you set up a redis cache? Regarding file locking, this reduces a lot the load on your sql server. Did you have a look at the FAQ article dedicated to this error message?

Thank you for your fast reply.
No, this happened for many files regardless of special characters.

I installed PHP 5.6 and updated apache2:

from apache2 2.2.22-13+deb7u7 to apache2_2.2.22-13+deb7u8_amd64
from php5 5.4.45-0+deb7u7 to php5_5.6.30-1~dotdeb+7.1_all

After that the warning message in the web view disappeared and now my files are writable again:

-rw-r--r-- 1 user group 24086 16 Jul 2011 #Briefvorlage.odt
-rw-r--r-- 1 user group 34735 16 Apr 2011 #Briefvorlage.ott
-rw-r--r-- 1 user group 86413 16 Jul 2011 #Briefvorlage.pdf

I also configured the APCu cache and now no warning messages are displayed at all:

Security & setup warnings
All checks passed.

I think the problem has been resolved. Thank you very much again.