IUserMountCache.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author szaimen <szaimen@e.mail.de>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCP\Files\Config;
  26. use OCP\Files\Mount\IMountPoint;
  27. use OCP\Files\NotFoundException;
  28. use OCP\IUser;
  29. /**
  30. * Cache mounts points per user in the cache so we can easily look them up
  31. *
  32. * @since 9.0.0
  33. */
  34. interface IUserMountCache {
  35. /**
  36. * Register mounts for a user to the cache
  37. *
  38. * @param IUser $user
  39. * @param IMountPoint[] $mounts
  40. * @param array|null $mountProviderClasses
  41. * @since 9.0.0
  42. */
  43. public function registerMounts(IUser $user, array $mounts, ?array $mountProviderClasses = null);
  44. /**
  45. * Get all cached mounts for a user
  46. *
  47. * @param IUser $user
  48. * @return ICachedMountInfo[]
  49. * @since 9.0.0
  50. */
  51. public function getMountsForUser(IUser $user);
  52. /**
  53. * Get all cached mounts by storage
  54. *
  55. * @param int $numericStorageId
  56. * @param string|null $user limit the results to a single user @since 12.0.0
  57. * @return ICachedMountInfo[]
  58. * @since 9.0.0
  59. */
  60. public function getMountsForStorageId($numericStorageId, $user = null);
  61. /**
  62. * Get all cached mounts by root
  63. *
  64. * @param int $rootFileId
  65. * @return ICachedMountInfo[]
  66. * @since 9.0.0
  67. */
  68. public function getMountsForRootId($rootFileId);
  69. /**
  70. * Get all cached mounts that contain a file
  71. *
  72. * @param int $fileId
  73. * @param string|null $user optionally restrict the results to a single user @since 12.0.0
  74. * @return ICachedMountFileInfo[]
  75. * @since 9.0.0
  76. */
  77. public function getMountsForFileId($fileId, $user = null);
  78. /**
  79. * Remove all cached mounts for a user
  80. *
  81. * @param IUser $user
  82. * @since 9.0.0
  83. */
  84. public function removeUserMounts(IUser $user);
  85. /**
  86. * Remove all mounts for a user and storage
  87. *
  88. * @param $storageId
  89. * @param string $userId
  90. * @return mixed
  91. * @since 9.0.0
  92. */
  93. public function removeUserStorageMount($storageId, $userId);
  94. /**
  95. * Remove all cached mounts for a storage
  96. *
  97. * @param $storageId
  98. * @return mixed
  99. * @since 9.0.0
  100. */
  101. public function remoteStorageMounts($storageId);
  102. /**
  103. * Get the used space for users
  104. *
  105. * Note that this only includes the space in their home directory,
  106. * not any incoming shares or external storage.
  107. *
  108. * @param IUser[] $users
  109. * @return int[] [$userId => $userSpace]
  110. * @since 13.0.0
  111. */
  112. public function getUsedSpaceForUsers(array $users);
  113. /**
  114. * Clear all entries from the in-memory cache
  115. *
  116. * @since 20.0.0
  117. */
  118. public function clear(): void;
  119. /**
  120. * Get all cached mounts for a user
  121. *
  122. * @param IUser $user
  123. * @param string $path
  124. * @return ICachedMountInfo
  125. * @throws NotFoundException
  126. * @since 24.0.0
  127. */
  128. public function getMountForPath(IUser $user, string $path): ICachedMountInfo;
  129. /**
  130. * Get all cached mounts for a user inside a path
  131. *
  132. * @param IUser $user
  133. * @param string $path
  134. * @return ICachedMountInfo[]
  135. * @throws NotFoundException
  136. * @since 24.0.0
  137. */
  138. public function getMountsInPath(IUser $user, string $path): array;
  139. }