SetupManager.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Files;
  8. use OC\Files\Config\MountProviderCollection;
  9. use OC\Files\Mount\HomeMountPoint;
  10. use OC\Files\Mount\MountPoint;
  11. use OC\Files\Storage\Common;
  12. use OC\Files\Storage\Home;
  13. use OC\Files\Storage\Storage;
  14. use OC\Files\Storage\Wrapper\Availability;
  15. use OC\Files\Storage\Wrapper\Encoding;
  16. use OC\Files\Storage\Wrapper\PermissionsMask;
  17. use OC\Files\Storage\Wrapper\Quota;
  18. use OC\Lockdown\Filesystem\NullStorage;
  19. use OC\Share\Share;
  20. use OC\Share20\ShareDisableChecker;
  21. use OC_App;
  22. use OC_Hook;
  23. use OC_Util;
  24. use OCA\Files_External\Config\ConfigAdapter;
  25. use OCA\Files_Sharing\External\Mount;
  26. use OCA\Files_Sharing\ISharedMountPoint;
  27. use OCA\Files_Sharing\SharedMount;
  28. use OCP\Constants;
  29. use OCP\Diagnostics\IEventLogger;
  30. use OCP\EventDispatcher\IEventDispatcher;
  31. use OCP\Files\Config\ICachedMountInfo;
  32. use OCP\Files\Config\IHomeMountProvider;
  33. use OCP\Files\Config\IMountProvider;
  34. use OCP\Files\Config\IUserMountCache;
  35. use OCP\Files\Events\InvalidateMountCacheEvent;
  36. use OCP\Files\Events\Node\FilesystemTornDownEvent;
  37. use OCP\Files\Mount\IMountManager;
  38. use OCP\Files\Mount\IMountPoint;
  39. use OCP\Files\NotFoundException;
  40. use OCP\Files\Storage\IStorage;
  41. use OCP\Group\Events\UserAddedEvent;
  42. use OCP\Group\Events\UserRemovedEvent;
  43. use OCP\ICache;
  44. use OCP\ICacheFactory;
  45. use OCP\IConfig;
  46. use OCP\IUser;
  47. use OCP\IUserManager;
  48. use OCP\IUserSession;
  49. use OCP\Lockdown\ILockdownManager;
  50. use OCP\Share\Events\ShareCreatedEvent;
  51. use Psr\Log\LoggerInterface;
  52. class SetupManager {
  53. private bool $rootSetup = false;
  54. // List of users for which at least one mount is setup
  55. private array $setupUsers = [];
  56. // List of users for which all mounts are setup
  57. private array $setupUsersComplete = [];
  58. /** @var array<string, string[]> */
  59. private array $setupUserMountProviders = [];
  60. private ICache $cache;
  61. private bool $listeningForProviders;
  62. private array $fullSetupRequired = [];
  63. private bool $setupBuiltinWrappersDone = false;
  64. private bool $forceFullSetup = false;
  65. public function __construct(
  66. private IEventLogger $eventLogger,
  67. private MountProviderCollection $mountProviderCollection,
  68. private IMountManager $mountManager,
  69. private IUserManager $userManager,
  70. private IEventDispatcher $eventDispatcher,
  71. private IUserMountCache $userMountCache,
  72. private ILockdownManager $lockdownManager,
  73. private IUserSession $userSession,
  74. ICacheFactory $cacheFactory,
  75. private LoggerInterface $logger,
  76. private IConfig $config,
  77. private ShareDisableChecker $shareDisableChecker,
  78. ) {
  79. $this->cache = $cacheFactory->createDistributed('setupmanager::');
  80. $this->listeningForProviders = false;
  81. $this->forceFullSetup = $this->config->getSystemValueBool('debug.force-full-fs-setup');
  82. $this->setupListeners();
  83. }
  84. private function isSetupStarted(IUser $user): bool {
  85. return in_array($user->getUID(), $this->setupUsers, true);
  86. }
  87. public function isSetupComplete(IUser $user): bool {
  88. return in_array($user->getUID(), $this->setupUsersComplete, true);
  89. }
  90. private function setupBuiltinWrappers() {
  91. if ($this->setupBuiltinWrappersDone) {
  92. return;
  93. }
  94. $this->setupBuiltinWrappersDone = true;
  95. // load all filesystem apps before, so no setup-hook gets lost
  96. OC_App::loadApps(['filesystem']);
  97. $prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
  98. Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
  99. if ($storage->instanceOfStorage(Common::class)) {
  100. $options = array_merge($mount->getOptions(), ['mount_point' => $mountPoint]);
  101. $storage->setMountOptions($options);
  102. }
  103. return $storage;
  104. });
  105. $reSharingEnabled = Share::isResharingAllowed();
  106. $user = $this->userSession->getUser();
  107. $sharingEnabledForUser = $user ? !$this->shareDisableChecker->sharingDisabledForUser($user->getUID()) : true;
  108. Filesystem::addStorageWrapper(
  109. 'sharing_mask',
  110. function ($mountPoint, IStorage $storage, IMountPoint $mount) use ($reSharingEnabled, $sharingEnabledForUser) {
  111. $sharingEnabledForMount = $mount->getOption('enable_sharing', true);
  112. $isShared = $mount instanceof ISharedMountPoint;
  113. if (!$sharingEnabledForMount || !$sharingEnabledForUser || (!$reSharingEnabled && $isShared)) {
  114. return new PermissionsMask([
  115. 'storage' => $storage,
  116. 'mask' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE,
  117. ]);
  118. }
  119. return $storage;
  120. }
  121. );
  122. // install storage availability wrapper, before most other wrappers
  123. Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
  124. $externalMount = $mount instanceof ConfigAdapter || $mount instanceof Mount;
  125. if ($externalMount && !$storage->isLocal()) {
  126. return new Availability(['storage' => $storage]);
  127. }
  128. return $storage;
  129. });
  130. Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
  131. if ($mount->getOption('encoding_compatibility', false) && !$mount instanceof SharedMount) {
  132. return new Encoding(['storage' => $storage]);
  133. }
  134. return $storage;
  135. });
  136. $quotaIncludeExternal = $this->config->getSystemValue('quota_include_external_storage', false);
  137. Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage, IMountPoint $mount) use ($quotaIncludeExternal) {
  138. // set up quota for home storages, even for other users
  139. // which can happen when using sharing
  140. if ($mount instanceof HomeMountPoint) {
  141. $user = $mount->getUser();
  142. return new Quota(['storage' => $storage, 'quotaCallback' => function () use ($user) {
  143. return OC_Util::getUserQuota($user);
  144. }, 'root' => 'files', 'include_external_storage' => $quotaIncludeExternal]);
  145. }
  146. return $storage;
  147. });
  148. Filesystem::addStorageWrapper('readonly', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
  149. /*
  150. * Do not allow any operations that modify the storage
  151. */
  152. if ($mount->getOption('readonly', false)) {
  153. return new PermissionsMask([
  154. 'storage' => $storage,
  155. 'mask' => Constants::PERMISSION_ALL & ~(
  156. Constants::PERMISSION_UPDATE |
  157. Constants::PERMISSION_CREATE |
  158. Constants::PERMISSION_DELETE
  159. ),
  160. ]);
  161. }
  162. return $storage;
  163. });
  164. Filesystem::logWarningWhenAddingStorageWrapper($prevLogging);
  165. }
  166. /**
  167. * Setup the full filesystem for the specified user
  168. */
  169. public function setupForUser(IUser $user): void {
  170. if ($this->isSetupComplete($user)) {
  171. return;
  172. }
  173. $this->setupUsersComplete[] = $user->getUID();
  174. $this->eventLogger->start('fs:setup:user:full', 'Setup full filesystem for user');
  175. if (!isset($this->setupUserMountProviders[$user->getUID()])) {
  176. $this->setupUserMountProviders[$user->getUID()] = [];
  177. }
  178. $previouslySetupProviders = $this->setupUserMountProviders[$user->getUID()];
  179. $this->setupForUserWith($user, function () use ($user) {
  180. $this->mountProviderCollection->addMountForUser($user, $this->mountManager, function (
  181. IMountProvider $provider
  182. ) use ($user) {
  183. return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
  184. });
  185. });
  186. $this->afterUserFullySetup($user, $previouslySetupProviders);
  187. $this->eventLogger->end('fs:setup:user:full');
  188. }
  189. /**
  190. * part of the user setup that is run only once per user
  191. */
  192. private function oneTimeUserSetup(IUser $user) {
  193. if ($this->isSetupStarted($user)) {
  194. return;
  195. }
  196. $this->setupUsers[] = $user->getUID();
  197. $this->setupRoot();
  198. $this->eventLogger->start('fs:setup:user:onetime', 'Onetime filesystem for user');
  199. $this->setupBuiltinWrappers();
  200. $prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
  201. OC_Hook::emit('OC_Filesystem', 'preSetup', ['user' => $user->getUID()]);
  202. Filesystem::logWarningWhenAddingStorageWrapper($prevLogging);
  203. $userDir = '/' . $user->getUID() . '/files';
  204. Filesystem::initInternal($userDir);
  205. if ($this->lockdownManager->canAccessFilesystem()) {
  206. $this->eventLogger->start('fs:setup:user:home', 'Setup home filesystem for user');
  207. // home mounts are handled separate since we need to ensure this is mounted before we call the other mount providers
  208. $homeMount = $this->mountProviderCollection->getHomeMountForUser($user);
  209. $this->mountManager->addMount($homeMount);
  210. if ($homeMount->getStorageRootId() === -1) {
  211. $this->eventLogger->start('fs:setup:user:home:scan', 'Scan home filesystem for user');
  212. $homeMount->getStorage()->mkdir('');
  213. $homeMount->getStorage()->getScanner()->scan('');
  214. $this->eventLogger->end('fs:setup:user:home:scan');
  215. }
  216. $this->eventLogger->end('fs:setup:user:home');
  217. } else {
  218. $this->mountManager->addMount(new MountPoint(
  219. new NullStorage([]),
  220. '/' . $user->getUID()
  221. ));
  222. $this->mountManager->addMount(new MountPoint(
  223. new NullStorage([]),
  224. '/' . $user->getUID() . '/files'
  225. ));
  226. $this->setupUsersComplete[] = $user->getUID();
  227. }
  228. $this->listenForNewMountProviders();
  229. $this->eventLogger->end('fs:setup:user:onetime');
  230. }
  231. /**
  232. * Final housekeeping after a user has been fully setup
  233. */
  234. private function afterUserFullySetup(IUser $user, array $previouslySetupProviders): void {
  235. $this->eventLogger->start('fs:setup:user:full:post', 'Housekeeping after user is setup');
  236. $userRoot = '/' . $user->getUID() . '/';
  237. $mounts = $this->mountManager->getAll();
  238. $mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
  239. return str_starts_with($mount->getMountPoint(), $userRoot);
  240. });
  241. $allProviders = array_map(function (IMountProvider $provider) {
  242. return get_class($provider);
  243. }, $this->mountProviderCollection->getProviders());
  244. $newProviders = array_diff($allProviders, $previouslySetupProviders);
  245. $mounts = array_filter($mounts, function (IMountPoint $mount) use ($previouslySetupProviders) {
  246. return !in_array($mount->getMountProvider(), $previouslySetupProviders);
  247. });
  248. $this->userMountCache->registerMounts($user, $mounts, $newProviders);
  249. $cacheDuration = $this->config->getSystemValueInt('fs_mount_cache_duration', 5 * 60);
  250. if ($cacheDuration > 0) {
  251. $this->cache->set($user->getUID(), true, $cacheDuration);
  252. $this->fullSetupRequired[$user->getUID()] = false;
  253. }
  254. $this->eventLogger->end('fs:setup:user:full:post');
  255. }
  256. /**
  257. * @param IUser $user
  258. * @param IMountPoint $mounts
  259. * @return void
  260. * @throws \OCP\HintException
  261. * @throws \OC\ServerNotAvailableException
  262. */
  263. private function setupForUserWith(IUser $user, callable $mountCallback): void {
  264. $this->oneTimeUserSetup($user);
  265. if ($this->lockdownManager->canAccessFilesystem()) {
  266. $mountCallback();
  267. }
  268. $this->eventLogger->start('fs:setup:user:post-init-mountpoint', 'post_initMountPoints legacy hook');
  269. \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', ['user' => $user->getUID()]);
  270. $this->eventLogger->end('fs:setup:user:post-init-mountpoint');
  271. $userDir = '/' . $user->getUID() . '/files';
  272. $this->eventLogger->start('fs:setup:user:setup-hook', 'setup legacy hook');
  273. OC_Hook::emit('OC_Filesystem', 'setup', ['user' => $user->getUID(), 'user_dir' => $userDir]);
  274. $this->eventLogger->end('fs:setup:user:setup-hook');
  275. }
  276. /**
  277. * Set up the root filesystem
  278. */
  279. public function setupRoot(): void {
  280. //setting up the filesystem twice can only lead to trouble
  281. if ($this->rootSetup) {
  282. return;
  283. }
  284. $this->setupBuiltinWrappers();
  285. $this->rootSetup = true;
  286. $this->eventLogger->start('fs:setup:root', 'Setup root filesystem');
  287. $rootMounts = $this->mountProviderCollection->getRootMounts();
  288. foreach ($rootMounts as $rootMountProvider) {
  289. $this->mountManager->addMount($rootMountProvider);
  290. }
  291. $this->eventLogger->end('fs:setup:root');
  292. }
  293. /**
  294. * Get the user to setup for a path or `null` if the root needs to be setup
  295. *
  296. * @param string $path
  297. * @return IUser|null
  298. */
  299. private function getUserForPath(string $path) {
  300. if (str_starts_with($path, '/__groupfolders')) {
  301. return null;
  302. } elseif (substr_count($path, '/') < 2) {
  303. if ($user = $this->userSession->getUser()) {
  304. return $user;
  305. } else {
  306. return null;
  307. }
  308. } elseif (str_starts_with($path, '/appdata_' . \OC_Util::getInstanceId()) || str_starts_with($path, '/files_external/')) {
  309. return null;
  310. } else {
  311. [, $userId] = explode('/', $path);
  312. }
  313. return $this->userManager->get($userId);
  314. }
  315. /**
  316. * Set up the filesystem for the specified path
  317. */
  318. public function setupForPath(string $path, bool $includeChildren = false): void {
  319. $user = $this->getUserForPath($path);
  320. if (!$user) {
  321. $this->setupRoot();
  322. return;
  323. }
  324. if ($this->isSetupComplete($user)) {
  325. return;
  326. }
  327. if ($this->fullSetupRequired($user)) {
  328. $this->setupForUser($user);
  329. return;
  330. }
  331. // for the user's home folder, and includes children we need everything always
  332. if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) {
  333. $this->setupForUser($user);
  334. return;
  335. }
  336. if (!isset($this->setupUserMountProviders[$user->getUID()])) {
  337. $this->setupUserMountProviders[$user->getUID()] = [];
  338. }
  339. $setupProviders = &$this->setupUserMountProviders[$user->getUID()];
  340. $currentProviders = [];
  341. try {
  342. $cachedMount = $this->userMountCache->getMountForPath($user, $path);
  343. } catch (NotFoundException $e) {
  344. $this->setupForUser($user);
  345. return;
  346. }
  347. $this->oneTimeUserSetup($user);
  348. $this->eventLogger->start('fs:setup:user:path', "Setup $path filesystem for user");
  349. $this->eventLogger->start('fs:setup:user:path:find', "Find mountpoint for $path");
  350. $mounts = [];
  351. if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
  352. $currentProviders[] = $cachedMount->getMountProvider();
  353. if ($cachedMount->getMountProvider()) {
  354. $setupProviders[] = $cachedMount->getMountProvider();
  355. $mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]);
  356. } else {
  357. $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
  358. $this->eventLogger->end('fs:setup:user:path:find');
  359. $this->setupForUser($user);
  360. $this->eventLogger->end('fs:setup:user:path');
  361. return;
  362. }
  363. }
  364. if ($includeChildren) {
  365. $subCachedMounts = $this->userMountCache->getMountsInPath($user, $path);
  366. $this->eventLogger->end('fs:setup:user:path:find');
  367. $needsFullSetup = array_reduce($subCachedMounts, function (bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) {
  368. return $needsFullSetup || $cachedMountInfo->getMountProvider() === '';
  369. }, false);
  370. if ($needsFullSetup) {
  371. $this->logger->debug("mount has no provider set, performing full setup");
  372. $this->setupForUser($user);
  373. $this->eventLogger->end('fs:setup:user:path');
  374. return;
  375. } else {
  376. foreach ($subCachedMounts as $cachedMount) {
  377. if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
  378. $currentProviders[] = $cachedMount->getMountProvider();
  379. $setupProviders[] = $cachedMount->getMountProvider();
  380. $mounts = array_merge($mounts, $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]));
  381. }
  382. }
  383. }
  384. } else {
  385. $this->eventLogger->end('fs:setup:user:path:find');
  386. }
  387. if (count($mounts)) {
  388. $this->userMountCache->registerMounts($user, $mounts, $currentProviders);
  389. $this->setupForUserWith($user, function () use ($mounts) {
  390. array_walk($mounts, [$this->mountManager, 'addMount']);
  391. });
  392. } elseif (!$this->isSetupStarted($user)) {
  393. $this->oneTimeUserSetup($user);
  394. }
  395. $this->eventLogger->end('fs:setup:user:path');
  396. }
  397. private function fullSetupRequired(IUser $user): bool {
  398. if ($this->forceFullSetup) {
  399. return true;
  400. }
  401. // we perform a "cached" setup only after having done the full setup recently
  402. // this is also used to trigger a full setup after handling events that are likely
  403. // to change the available mounts
  404. if (!isset($this->fullSetupRequired[$user->getUID()])) {
  405. $this->fullSetupRequired[$user->getUID()] = !$this->cache->get($user->getUID());
  406. }
  407. return $this->fullSetupRequired[$user->getUID()];
  408. }
  409. /**
  410. * @param string $path
  411. * @param string[] $providers
  412. */
  413. public function setupForProvider(string $path, array $providers): void {
  414. $user = $this->getUserForPath($path);
  415. if (!$user) {
  416. $this->setupRoot();
  417. return;
  418. }
  419. if ($this->isSetupComplete($user)) {
  420. return;
  421. }
  422. if ($this->fullSetupRequired($user)) {
  423. $this->setupForUser($user);
  424. return;
  425. }
  426. $this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for " . implode(', ', $providers));
  427. $this->oneTimeUserSetup($user);
  428. // home providers are always used
  429. $providers = array_filter($providers, function (string $provider) {
  430. return !is_subclass_of($provider, IHomeMountProvider::class);
  431. });
  432. if (in_array('', $providers)) {
  433. $this->setupForUser($user);
  434. return;
  435. }
  436. $setupProviders = $this->setupUserMountProviders[$user->getUID()] ?? [];
  437. $providers = array_diff($providers, $setupProviders);
  438. if (count($providers) === 0) {
  439. if (!$this->isSetupStarted($user)) {
  440. $this->oneTimeUserSetup($user);
  441. }
  442. $this->eventLogger->end('fs:setup:user:providers');
  443. return;
  444. } else {
  445. $this->setupUserMountProviders[$user->getUID()] = array_merge($setupProviders, $providers);
  446. $mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, $providers);
  447. }
  448. $this->userMountCache->registerMounts($user, $mounts, $providers);
  449. $this->setupForUserWith($user, function () use ($mounts) {
  450. array_walk($mounts, [$this->mountManager, 'addMount']);
  451. });
  452. $this->eventLogger->end('fs:setup:user:providers');
  453. }
  454. public function tearDown() {
  455. $this->setupUsers = [];
  456. $this->setupUsersComplete = [];
  457. $this->setupUserMountProviders = [];
  458. $this->fullSetupRequired = [];
  459. $this->rootSetup = false;
  460. $this->mountManager->clear();
  461. $this->eventDispatcher->dispatchTyped(new FilesystemTornDownEvent());
  462. }
  463. /**
  464. * Get mounts from mount providers that are registered after setup
  465. */
  466. private function listenForNewMountProviders() {
  467. if (!$this->listeningForProviders) {
  468. $this->listeningForProviders = true;
  469. $this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function (
  470. IMountProvider $provider
  471. ) {
  472. foreach ($this->setupUsers as $userId) {
  473. $user = $this->userManager->get($userId);
  474. if ($user) {
  475. $mounts = $provider->getMountsForUser($user, Filesystem::getLoader());
  476. array_walk($mounts, [$this->mountManager, 'addMount']);
  477. }
  478. }
  479. });
  480. }
  481. }
  482. private function setupListeners() {
  483. // note that this event handling is intentionally pessimistic
  484. // clearing the cache to often is better than not enough
  485. $this->eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event) {
  486. $this->cache->remove($event->getUser()->getUID());
  487. });
  488. $this->eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event) {
  489. $this->cache->remove($event->getUser()->getUID());
  490. });
  491. $this->eventDispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) {
  492. $this->cache->remove($event->getShare()->getSharedWith());
  493. });
  494. $this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function (InvalidateMountCacheEvent $event
  495. ) {
  496. if ($user = $event->getUser()) {
  497. $this->cache->remove($user->getUID());
  498. } else {
  499. $this->cache->clear();
  500. }
  501. });
  502. $genericEvents = [
  503. 'OCA\Circles\Events\CreatingCircleEvent',
  504. 'OCA\Circles\Events\DestroyingCircleEvent',
  505. 'OCA\Circles\Events\AddingCircleMemberEvent',
  506. 'OCA\Circles\Events\RemovingCircleMemberEvent',
  507. ];
  508. foreach ($genericEvents as $genericEvent) {
  509. $this->eventDispatcher->addListener($genericEvent, function ($event) {
  510. $this->cache->clear();
  511. });
  512. }
  513. }
  514. }