1
0

LazyStorageMountInfo.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 OC\Files\Config;
  8. use OCP\Files\Mount\IMountPoint;
  9. use OCP\IUser;
  10. class LazyStorageMountInfo extends CachedMountInfo {
  11. private IMountPoint $mount;
  12. /**
  13. * CachedMountInfo constructor.
  14. *
  15. * @param IUser $user
  16. * @param IMountPoint $mount
  17. */
  18. public function __construct(IUser $user, IMountPoint $mount) {
  19. $this->user = $user;
  20. $this->mount = $mount;
  21. $this->rootId = 0;
  22. $this->storageId = 0;
  23. $this->mountPoint = '';
  24. $this->key = '';
  25. }
  26. /**
  27. * @return int the numeric storage id of the mount
  28. */
  29. public function getStorageId(): int {
  30. if (!$this->storageId) {
  31. $this->storageId = $this->mount->getNumericStorageId();
  32. }
  33. return parent::getStorageId();
  34. }
  35. /**
  36. * @return int the fileid of the root of the mount
  37. */
  38. public function getRootId(): int {
  39. if (!$this->rootId) {
  40. $this->rootId = $this->mount->getStorageRootId();
  41. }
  42. return parent::getRootId();
  43. }
  44. /**
  45. * @return string the mount point of the mount for the user
  46. */
  47. public function getMountPoint(): string {
  48. if (!$this->mountPoint) {
  49. $this->mountPoint = $this->mount->getMountPoint();
  50. }
  51. return parent::getMountPoint();
  52. }
  53. public function getMountId(): ?int {
  54. return $this->mount->getMountId();
  55. }
  56. /**
  57. * Get the internal path (within the storage) of the root of the mount
  58. *
  59. * @return string
  60. */
  61. public function getRootInternalPath(): string {
  62. return $this->mount->getInternalPath($this->mount->getMountPoint());
  63. }
  64. public function getMountProvider(): string {
  65. return $this->mount->getMountProvider();
  66. }
  67. public function getKey(): string {
  68. if (!$this->key) {
  69. $this->key = $this->getRootId() . '::' . $this->getMountPoint();
  70. }
  71. return $this->key;
  72. }
  73. }