Cache.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. private $remote;
  11. private $remoteUser;
  12. /**
  13. * @param Storage $storage
  14. * @param ICloudId $cloudId
  15. */
  16. public function __construct(
  17. private $storage,
  18. private ICloudId $cloudId,
  19. ) {
  20. [, $remote] = explode('://', $this->cloudId->getRemote(), 2);
  21. $this->remote = $remote;
  22. $this->remoteUser = $this->cloudId->getUser();
  23. parent::__construct($this->storage);
  24. }
  25. public function get($file) {
  26. $result = parent::get($file);
  27. if (!$result) {
  28. return false;
  29. }
  30. $result['displayname_owner'] = $this->cloudId->getDisplayId();
  31. if (!$file || $file === '') {
  32. $result['is_share_mount_point'] = true;
  33. $mountPoint = rtrim($this->storage->getMountPoint());
  34. $result['name'] = basename($mountPoint);
  35. }
  36. return $result;
  37. }
  38. public function getFolderContentsById($fileId) {
  39. $results = parent::getFolderContentsById($fileId);
  40. foreach ($results as &$file) {
  41. $file['displayname_owner'] = $this->cloudId->getDisplayId();
  42. }
  43. return $results;
  44. }
  45. }