SetupManager.php 19 KB

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