IUserMountCache.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Files\Config;
  8. use OCP\Files\Mount\IMountPoint;
  9. use OCP\Files\NotFoundException;
  10. use OCP\IUser;
  11. /**
  12. * Cache mounts points per user in the cache so we can easily look them up
  13. *
  14. * @since 9.0.0
  15. */
  16. interface IUserMountCache {
  17. /**
  18. * Register mounts for a user to the cache
  19. *
  20. * @param IUser $user
  21. * @param IMountPoint[] $mounts
  22. * @param array|null $mountProviderClasses
  23. * @since 9.0.0
  24. */
  25. public function registerMounts(IUser $user, array $mounts, ?array $mountProviderClasses = null);
  26. /**
  27. * Get all cached mounts for a user
  28. *
  29. * @param IUser $user
  30. * @return ICachedMountInfo[]
  31. * @since 9.0.0
  32. */
  33. public function getMountsForUser(IUser $user);
  34. /**
  35. * Get all cached mounts by storage
  36. *
  37. * @param int $numericStorageId
  38. * @param string|null $user limit the results to a single user @since 12.0.0
  39. * @return ICachedMountInfo[]
  40. * @since 9.0.0
  41. */
  42. public function getMountsForStorageId($numericStorageId, $user = null);
  43. /**
  44. * Get all cached mounts by root
  45. *
  46. * @param int $rootFileId
  47. * @return ICachedMountInfo[]
  48. * @since 9.0.0
  49. */
  50. public function getMountsForRootId($rootFileId);
  51. /**
  52. * Get all cached mounts that contain a file
  53. *
  54. * @param int $fileId
  55. * @param string|null $user optionally restrict the results to a single user @since 12.0.0
  56. * @return ICachedMountFileInfo[]
  57. * @since 9.0.0
  58. */
  59. public function getMountsForFileId($fileId, $user = null);
  60. /**
  61. * Remove all cached mounts for a user
  62. *
  63. * @param IUser $user
  64. * @since 9.0.0
  65. */
  66. public function removeUserMounts(IUser $user);
  67. /**
  68. * Remove all mounts for a user and storage
  69. *
  70. * @param $storageId
  71. * @param string $userId
  72. * @return mixed
  73. * @since 9.0.0
  74. */
  75. public function removeUserStorageMount($storageId, $userId);
  76. /**
  77. * Remove all cached mounts for a storage
  78. *
  79. * @param $storageId
  80. * @return mixed
  81. * @since 9.0.0
  82. */
  83. public function remoteStorageMounts($storageId);
  84. /**
  85. * Get the used space for users
  86. *
  87. * Note that this only includes the space in their home directory,
  88. * not any incoming shares or external storage.
  89. *
  90. * @param IUser[] $users
  91. * @return int[] [$userId => $userSpace]
  92. * @since 13.0.0
  93. */
  94. public function getUsedSpaceForUsers(array $users);
  95. /**
  96. * Clear all entries from the in-memory cache
  97. *
  98. * @since 20.0.0
  99. */
  100. public function clear(): void;
  101. /**
  102. * Get all cached mounts for a user
  103. *
  104. * @param IUser $user
  105. * @param string $path
  106. * @return ICachedMountInfo
  107. * @throws NotFoundException
  108. * @since 24.0.0
  109. */
  110. public function getMountForPath(IUser $user, string $path): ICachedMountInfo;
  111. /**
  112. * Get all cached mounts for a user inside a path
  113. *
  114. * @param IUser $user
  115. * @param string $path
  116. * @return ICachedMountInfo[]
  117. * @throws NotFoundException
  118. * @since 24.0.0
  119. */
  120. public function getMountsInPath(IUser $user, string $path): array;
  121. }