Get current user context

How do I get current user context in external files storage provider? I mean something that would work universally, in particular when executing occ command such as “occ files:scan --all”. I tried \OC_User::getUser(), but it does not seem to work. I also looked through code, but this did not give me any ideas unfortunately. Any help anyone?

I am not sure if I get the question right.

but for “–all” you need to loop the users in your app on your own.
I did it this way:

I am implementing a Storage interface and inside my implementation I need to know the context. I found a way to find out the user for which my provider is called by:
$user = \OC\Files\Filesystem::getOwner(’/’);

This looks somewhat hacky though. On the plus side it works for both normal operation and file scanning :slight_smile: