LazyStorageMountInfo.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /** @var IMountPoint */
  27. private $mount;
  28. /**
  29. * CachedMountInfo constructor.
  30. *
  31. * @param IUser $user
  32. * @param IMountPoint $mount
  33. */
  34. public function __construct(IUser $user, IMountPoint $mount) {
  35. $this->user = $user;
  36. $this->mount = $mount;
  37. }
  38. /**
  39. * @return int the numeric storage id of the mount
  40. */
  41. public function getStorageId() {
  42. if (!$this->storageId) {
  43. $this->storageId = $this->mount->getNumericStorageId();
  44. }
  45. return parent::getStorageId();
  46. }
  47. /**
  48. * @return int the fileid of the root of the mount
  49. */
  50. public function getRootId() {
  51. if (!$this->rootId) {
  52. $this->rootId = $this->mount->getStorageRootId();
  53. }
  54. return parent::getRootId();
  55. }
  56. /**
  57. * @return string the mount point of the mount for the user
  58. */
  59. public function getMountPoint() {
  60. if (!$this->mountPoint) {
  61. $this->mountPoint = $this->mount->getMountPoint();
  62. }
  63. return parent::getMountPoint();
  64. }
  65. public function getMountId() {
  66. return $this->mount->getMountId();
  67. }
  68. /**
  69. * Get the internal path (within the storage) of the root of the mount
  70. *
  71. * @return string
  72. */
  73. public function getRootInternalPath() {
  74. return $this->mount->getInternalPath($this->mount->getMountPoint());
  75. }
  76. }