Cache.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_Sharing\External;
  8. use OCP\Federation\ICloudId;
  9. class Cache extends \OC\Files\Cache\Cache {
  10. /** @var ICloudId */
  11. private $cloudId;
  12. private $remote;
  13. private $remoteUser;
  14. private $storage;
  15. /**
  16. * @param \OCA\Files_Sharing\External\Storage $storage
  17. * @param ICloudId $cloudId
  18. */
  19. public function __construct($storage, ICloudId $cloudId) {
  20. $this->cloudId = $cloudId;
  21. $this->storage = $storage;
  22. [, $remote] = explode('://', $cloudId->getRemote(), 2);
  23. $this->remote = $remote;
  24. $this->remoteUser = $cloudId->getUser();
  25. parent::__construct($storage);
  26. }
  27. public function get($file) {
  28. $result = parent::get($file);
  29. if (!$result) {
  30. return false;
  31. }
  32. $result['displayname_owner'] = $this->cloudId->getDisplayId();
  33. if (!$file || $file === '') {
  34. $result['is_share_mount_point'] = true;
  35. $mountPoint = rtrim($this->storage->getMountPoint());
  36. $result['name'] = basename($mountPoint);
  37. }
  38. return $result;
  39. }
  40. public function getFolderContentsById($fileId) {
  41. $results = parent::getFolderContentsById($fileId);
  42. foreach ($results as &$file) {
  43. $file['displayname_owner'] = $this->cloudId->getDisplayId();
  44. }
  45. return $results;
  46. }
  47. }