[WIP] try to keep the session lock time as short as possible

:construction: 

https://github.com/owncloud/core/issues/6937#issuecomment-34979380

@icewind1991 @karlitschek @bantu