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