backport  https://github.com/owncloud/core/pull/2411