Fix Issue 6553

Fixes this issue https://github.com/owncloud/core/issues/6553

- [ ] Write tests