[sharing] some small clean ups and bug fixes

- we can take the permission directly from the share, no need to call the share api first
- fix endless loop on windows server