use OCP\Files\Storage\IStorage;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
class SetupManager {
private IEventDispatcher $eventDispatcher;
private IUserMountCache $userMountCache;
private ILockdownManager $lockdownManager;
+ private IUserSession $userSession;
private bool $listeningForProviders;
public function __construct(
IUserManager $userManager,
IEventDispatcher $eventDispatcher,
IUserMountCache $userMountCache,
- ILockdownManager $lockdownManager
+ ILockdownManager $lockdownManager,
+ IUserSession $userSession
) {
$this->eventLogger = $eventLogger;
$this->mountProviderCollection = $mountProviderCollection;
$this->eventDispatcher = $eventDispatcher;
$this->userMountCache = $userMountCache;
$this->lockdownManager = $lockdownManager;
+ $this->userSession = $userSession;
$this->listeningForProviders = false;
}
* Set up the filesystem for the specified path
*/
public function setupForPath(string $path): void {
- if (substr_count($path, '/') < 2 || strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
+ if (substr_count($path, '/') < 2) {
+ if ($user = $this->userSession->getUser()) {
+ $this->setupForUser($user);
+ } else {
+ $this->setupRoot();
+ }
+ return;
+ } elseif (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
$this->setupRoot();
return;
} else {
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountManager;
use OCP\IUserManager;
+use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
class SetupManagerFactory {
private IEventDispatcher $eventDispatcher;
private IUserMountCache $userMountCache;
private ILockdownManager $lockdownManager;
+ private IUserSession $userSession;
private ?SetupManager $setupManager;
public function __construct(
IUserManager $userManager,
IEventDispatcher $eventDispatcher,
IUserMountCache $userMountCache,
- ILockdownManager $lockdownManager
+ ILockdownManager $lockdownManager,
+ IUserSession $userSession
) {
$this->eventLogger = $eventLogger;
$this->mountProviderCollection = $mountProviderCollection;
$this->eventDispatcher = $eventDispatcher;
$this->userMountCache = $userMountCache;
$this->lockdownManager = $lockdownManager;
+ $this->userSession = $userSession;
$this->setupManager = null;
}
public function create(IMountManager $mountManager): SetupManager {
if (!$this->setupManager) {
- $this->setupManager = new SetupManager($this->eventLogger, $this->mountProviderCollection, $mountManager, $this->userManager, $this->eventDispatcher, $this->userMountCache, $this->lockdownManager);
+ $this->setupManager = new SetupManager(
+ $this->eventLogger,
+ $this->mountProviderCollection,
+ $mountManager,
+ $this->userManager,
+ $this->eventDispatcher,
+ $this->userMountCache,
+ $this->lockdownManager,
+ $this->userSession,
+ );
}
return $this->setupManager;
}