LazyStorageMountInfo.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Files\Config;
  23. use OCP\Files\Mount\IMountPoint;
  24. use OCP\IUser;
  25. class LazyStorageMountInfo extends CachedMountInfo {
  26. private IMountPoint $mount;
  27. /**
  28. * CachedMountInfo constructor.
  29. *
  30. * @param IUser $user
  31. * @param IMountPoint $mount
  32. */
  33. public function __construct(IUser $user, IMountPoint $mount) {
  34. $this->user = $user;
  35. $this->mount = $mount;
  36. $this->rootId = 0;
  37. $this->storageId = 0;
  38. $this->mountPoint = '';
  39. }
  40. /**
  41. * @return int the numeric storage id of the mount
  42. */
  43. public function getStorageId(): int {
  44. if (!$this->storageId) {
  45. $this->storageId = $this->mount->getNumericStorageId();
  46. }
  47. return parent::getStorageId();
  48. }
  49. /**
  50. * @return int the fileid of the root of the mount
  51. */
  52. public function getRootId(): int {
  53. if (!$this->rootId) {
  54. $this->rootId = $this->mount->getStorageRootId();
  55. }
  56. return parent::getRootId();
  57. }
  58. /**
  59. * @return string the mount point of the mount for the user
  60. */
  61. public function getMountPoint(): string {
  62. if (!$this->mountPoint) {
  63. $this->mountPoint = $this->mount->getMountPoint();
  64. }
  65. return parent::getMountPoint();
  66. }
  67. public function getMountId(): ?int {
  68. return $this->mount->getMountId();
  69. }
  70. /**
  71. * Get the internal path (within the storage) of the root of the mount
  72. *
  73. * @return string
  74. */
  75. public function getRootInternalPath(): string {
  76. return $this->mount->getInternalPath($this->mount->getMountPoint());
  77. }
  78. public function getMountProvider(): string {
  79. return $this->mount->getMountProvider();
  80. }
  81. }