use OCP\Group\Events\UserRemovedEvent;
use OCP\ICache;
use OCP\ICacheFactory;
+use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
private IUserSession $userSession;
private ICache $cache;
private LoggerInterface $logger;
+ private IConfig $config;
private bool $listeningForProviders;
public function __construct(
ILockdownManager $lockdownManager,
IUserSession $userSession,
ICacheFactory $cacheFactory,
- LoggerInterface $logger
+ LoggerInterface $logger,
+ IConfig $config
) {
$this->eventLogger = $eventLogger;
$this->mountProviderCollection = $mountProviderCollection;
$this->userSession = $userSession;
$this->cache = $cacheFactory->createDistributed('setupmanager::');
$this->listeningForProviders = false;
+ $this->config = $config;
$this->setupListeners();
}
return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
});
});
- $this->userFullySetup($user);
+ $this->afterUserFullySetup($user);
}
/**
$this->listenForNewMountProviders();
}
- private function userFullySetup(IUser $user) {
+ /**
+ * Final housekeeping after a user has been fully setup
+ */
+ private function afterUserFullySetup(IUser $user): void {
$userRoot = '/' . $user->getUID() . '/';
$mounts = $this->mountManager->getAll();
$mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
$cachedSetup = $this->cache->get($user->getUID());
if (!$cachedSetup) {
$this->setupForUser($user);
- $this->cache->set($user->getUID(), true, 5 * 60);
+
+ $cacheDuration = $this->config->getSystemValueInt('fs_mount_cache_duration', 5 * 60);
+ if ($cacheDuration > 0) {
+ $this->cache->set($user->getUID(), true, $cacheDuration);
+ }
return;
}
}
if ($includeChildren) {
- $subCachedMounts = $this->userMountCache->getMountsInForPath($user, $path);
+ $subCachedMounts = $this->userMountCache->getMountsInPath($user, $path);
foreach ($subCachedMounts as $cachedMount) {
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
$setupProviders[] = $cachedMount->getMountProvider();
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountManager;
use OCP\ICacheFactory;
+use OCP\IConfig;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
private ?SetupManager $setupManager;
private ICacheFactory $cacheFactory;
private LoggerInterface $logger;
+ private IConfig $config;
public function __construct(
IEventLogger $eventLogger,
ILockdownManager $lockdownManager,
IUserSession $userSession,
ICacheFactory $cacheFactory,
- LoggerInterface $logger
+ LoggerInterface $logger,
+ IConfig $config
) {
$this->eventLogger = $eventLogger;
$this->mountProviderCollection = $mountProviderCollection;
$this->userSession = $userSession;
$this->cacheFactory = $cacheFactory;
$this->logger = $logger;
+ $this->config = $config;
$this->setupManager = null;
}
$this->lockdownManager,
$this->userSession,
$this->cacheFactory,
- $this->logger
+ $this->logger,
+ $this->config
);
}
return $this->setupManager;