mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
make mount cache duration configurable
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
63ad99ba4a
commit
b7a7425fbd
2 changed files with 23 additions and 7 deletions
|
|
@ -52,6 +52,7 @@ use OCP\Group\Events\UserAddedEvent;
|
|||
use OCP\Group\Events\UserRemovedEvent;
|
||||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
|
|
@ -77,6 +78,7 @@ class SetupManager {
|
|||
private IUserSession $userSession;
|
||||
private ICache $cache;
|
||||
private LoggerInterface $logger;
|
||||
private IConfig $config;
|
||||
private bool $listeningForProviders;
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -89,7 +91,8 @@ class SetupManager {
|
|||
ILockdownManager $lockdownManager,
|
||||
IUserSession $userSession,
|
||||
ICacheFactory $cacheFactory,
|
||||
LoggerInterface $logger
|
||||
LoggerInterface $logger,
|
||||
IConfig $config
|
||||
) {
|
||||
$this->eventLogger = $eventLogger;
|
||||
$this->mountProviderCollection = $mountProviderCollection;
|
||||
|
|
@ -102,6 +105,7 @@ class SetupManager {
|
|||
$this->userSession = $userSession;
|
||||
$this->cache = $cacheFactory->createDistributed('setupmanager::');
|
||||
$this->listeningForProviders = false;
|
||||
$this->config = $config;
|
||||
|
||||
$this->setupListeners();
|
||||
}
|
||||
|
|
@ -204,7 +208,7 @@ class SetupManager {
|
|||
return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
|
||||
});
|
||||
});
|
||||
$this->userFullySetup($user);
|
||||
$this->afterUserFullySetup($user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -249,7 +253,10 @@ class SetupManager {
|
|||
$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) {
|
||||
|
|
@ -348,7 +355,11 @@ class SetupManager {
|
|||
$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;
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +390,7 @@ class SetupManager {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use OCP\Files\Config\IMountProviderCollection;
|
|||
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;
|
||||
|
|
@ -45,6 +46,7 @@ class SetupManagerFactory {
|
|||
private ?SetupManager $setupManager;
|
||||
private ICacheFactory $cacheFactory;
|
||||
private LoggerInterface $logger;
|
||||
private IConfig $config;
|
||||
|
||||
public function __construct(
|
||||
IEventLogger $eventLogger,
|
||||
|
|
@ -55,7 +57,8 @@ class SetupManagerFactory {
|
|||
ILockdownManager $lockdownManager,
|
||||
IUserSession $userSession,
|
||||
ICacheFactory $cacheFactory,
|
||||
LoggerInterface $logger
|
||||
LoggerInterface $logger,
|
||||
IConfig $config
|
||||
) {
|
||||
$this->eventLogger = $eventLogger;
|
||||
$this->mountProviderCollection = $mountProviderCollection;
|
||||
|
|
@ -66,6 +69,7 @@ class SetupManagerFactory {
|
|||
$this->userSession = $userSession;
|
||||
$this->cacheFactory = $cacheFactory;
|
||||
$this->logger = $logger;
|
||||
$this->config = $config;
|
||||
$this->setupManager = null;
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +85,8 @@ class SetupManagerFactory {
|
|||
$this->lockdownManager,
|
||||
$this->userSession,
|
||||
$this->cacheFactory,
|
||||
$this->logger
|
||||
$this->logger,
|
||||
$this->config
|
||||
);
|
||||
}
|
||||
return $this->setupManager;
|
||||
|
|
|
|||
Loading…
Reference in a new issue