diff --git a/lib/Model/Mount.php b/lib/Model/Mount.php index db949ffb9..c570d68ad 100644 --- a/lib/Model/Mount.php +++ b/lib/Model/Mount.php @@ -42,7 +42,6 @@ class Mount extends ManagedModel implements IDeserializable, IQueryRow, JsonSeri private string $storage; private ICloudIdManager $cloudIdManager; private IClientService $httpClientService; - private CircleMountManager $mountManager; private string $remote = ''; private int $remoteShareId = 0; @@ -306,25 +305,6 @@ public function getHttpClientService(): IClientService { return $this->httpClientService; } - - /** - * @param CircleMountManager $mountManager - * - * @return Mount - */ - public function setMountManager(CircleMountManager $mountManager): self { - $this->mountManager = $mountManager; - - return $this; - } - - /** - * @return CircleMountManager - */ - public function getMountManager(): CircleMountManager { - return $this->mountManager; - } - public function setRemote(string $remote): void { $this->remote = $remote; } @@ -353,9 +333,7 @@ public function toMount(): array { 'token' => $this->getToken(), 'password' => $this->getPassword(), 'mountpoint' => $this->getMountPoint(false), - // 'manager' => $this->getMountManager(), 'HttpClientService' => $this->getHttpClientService(), - 'manager' => $this->getMountManager(), 'cloudId' => $this->getCloudIdManager()->getCloudId( $member->getUserId(), $member->getRemoteInstance()->getRoot() diff --git a/lib/MountManager/CircleMount.php b/lib/MountManager/CircleMount.php index 21d3ba6bf..14601e18b 100644 --- a/lib/MountManager/CircleMount.php +++ b/lib/MountManager/CircleMount.php @@ -14,40 +14,33 @@ use Exception; use JsonSerializable; use OC\Files\Mount\MountPoint; -use OC\Files\Mount\MoveableMount; use OCA\Circles\Exceptions\MountPointConstructionException; use OCA\Circles\Model\Mount; use OCA\Circles\Tools\Traits\TArrayTools; +use OCP\Files\Mount\IMovableMount; +use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorageFactory; +use Override; /** * Class CircleMount * * @package OCA\Circles\MountManager */ -class CircleMount extends MountPoint implements MoveableMount, JsonSerializable { +class CircleMount extends MountPoint implements JsonSerializable { use TArrayTools; - - /** @var Mount */ - private $mount; - - /** @var string */ - private $storageClass; - + /** @var class-string */ + private string $storageClass; /** - * CircleMount constructor. - * - * @param Mount $mount - * @param string $storage - * @param IStorageFactory|null $loader + * @param IStorage|class-string $storage * * @throws MountPointConstructionException */ public function __construct( - Mount $mount, - string $storage, + private Mount $mount, + IStorage|string $storage, ?IStorageFactory $loader = null, ) { try { @@ -57,54 +50,18 @@ public function __construct( $mount->toMount(), $loader ); - } catch (Exception $e) { + } catch (Exception) { throw new MountPointConstructionException(); } - $this->mount = $mount; - $this->storageClass = $storage; - } - - - /** - * Move the mount point to $target - * - * @param string $target the target mount point - * - * @return bool - */ - public function moveMount($target) { - $result = $this->mount->getMountManager()->renameShare($this->gsShareId, $target); - $this->setMountPoint($target); - - return $result; + $this->storageClass = $storage instanceof IStorage ? get_class($storage) : $storage; } - /** - * Remove the mount points - * - * @return mixed - * @return bool - */ - public function removeMount() { - return $this->mount->getMountManager()->unshare($this->gsShareId); - } - - - /** - * Get the type of mount point, used to distinguish things like shares and external storages - * in the web interface - * - * @return string - */ - public function getMountType() { + #[Override] + public function getMountType(): string { return 'shared'; } - public function getInitiator() { - } - - /** * @return array */ diff --git a/lib/MountManager/CircleMountManager.php b/lib/MountManager/CircleMountManager.php deleted file mode 100644 index 6990e8c86..000000000 --- a/lib/MountManager/CircleMountManager.php +++ /dev/null @@ -1,96 +0,0 @@ -userId = $userId; - $this->gsSharesRequest = $gsSharesRequest; - } - - - /** - * @param int $gsShareId - * @param string $target - * - * @return bool - */ - public function renameShare(int $gsShareId, string $target) { - try { - if ($target !== '-') { - $target = $this->stripPath($target); - $this->gsSharesRequest->getShareMountPointByPath($this->userId, $target); - - return false; - } - } catch (ShareNotFound $e) { - } - - $mountPoint = new GSShareMountpoint($gsShareId, $this->userId, $target); - try { - $this->gsSharesRequest->getShareMountPointById($gsShareId, $this->userId); - $this->gsSharesRequest->updateShareMountPoint($mountPoint); - } catch (ShareNotFound $e) { - $this->gsSharesRequest->generateShareMountPoint($mountPoint); - } - - return true; - } - - /** - * @param int $gsShareId - * - * @return bool - */ - public function unshare(int $gsShareId) { - return $this->renameShare($gsShareId, '-'); - } - - - /** - * remove '/user/files' from the path and trailing slashes - * - * @param string $path - * - * @return string - */ - protected function stripPath(string $path): string { - $prefix = '/' . $this->userId . '/files'; - - return rtrim(substr($path, strlen($prefix)), '/'); - } -} diff --git a/lib/MountManager/CircleMountProvider.php b/lib/MountManager/CircleMountProvider.php index 58c9ab27e..3e4fdd782 100644 --- a/lib/MountManager/CircleMountProvider.php +++ b/lib/MountManager/CircleMountProvider.php @@ -41,12 +41,12 @@ class CircleMountProvider implements IMountProvider { use TArrayTools; + /** @var class-string */ public const EXTERNAL_STORAGE = ExternalStorage::class; public function __construct( private IClientService $clientService, private IRootFolder $rootFolder, - private CircleMountManager $circleMountManager, private ICloudIdManager $cloudIdManager, private MountRequest $mountRequest, private MountPointRequest $mountPointRequest, @@ -57,9 +57,6 @@ public function __construct( } /** - * @param IUser $user - * @param IStorageFactory $loader - * * @return list * @throws RequestBuilderException * @throws FederatedUserException @@ -86,10 +83,6 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader): array { /** - * @param Mount $mount - * @param IStorageFactory $storageFactory - * - * @return CircleMount * @throws InitiatorNotFoundException * @throws MountPointConstructionException */ @@ -103,9 +96,7 @@ public function generateCircleMount(Mount $mount, IStorageFactory $storageFactor } $mount->setCloudIdManager($this->cloudIdManager) - ->setHttpClientService($this->clientService) -// ->setStorage(self::EXTERNAL_STORAGE) - ->setMountManager($this->circleMountManager); + ->setHttpClientService($this->clientService); return new CircleMount( $mount, @@ -114,75 +105,6 @@ public function generateCircleMount(Mount $mount, IStorageFactory $storageFactor ); } - - /** - * @param int $gsShareId - * @param string $target - * - * @return bool - */ - public function renameShare(int $gsShareId, string $target) { - // try { - // if ($target !== '-') { - // $target = $this->stripPath($target); - // $this->gsSharesRequest->getShareMountPointByPath($this->userId, $target); - // - // return false; - // } - // } catch (ShareNotFound $e) { - // } - // - // $mountPoint = new GSShareMountpoint($gsShareId, $this->userId, $target); - // try { - // $this->gsSharesRequest->getShareMountPointById($gsShareId, $this->userId); - // $this->gsSharesRequest->updateShareMountPoint($mountPoint); - // } catch (ShareNotFound $e) { - // $this->gsSharesRequest->generateShareMountPoint($mountPoint); - // } - - return true; - } - - - // TODO: implement ! - public function getMountManager() { - return $this; - } - - // TODO: implement ! - public function removeShare($mountPoint) { - } - - // TODO: implement ! - public function removeMount($mountPoint) { - } - - - /** - * @param int $gsShareId - * - * @return bool - */ - public function unshare(int $gsShareId) { - return $this->renameShare($gsShareId, '-'); - } - - - /** - * remove '/user/files' from the path and trailing slashes - * - * @param string $path - * - * @return string - */ - protected function stripPath($path) { - return $path; - // $prefix = '/' . $this->userId . '/files'; - // - // return rtrim(substr($path, strlen($prefix)), '/'); - } - - private function fixDuplicateFile(string $userId, Mount $mount): void { if ($mount->getOriginalMountPoint() === '-') { return; diff --git a/psalm.xml b/psalm.xml index 9f4e727cf..3daa9b533 100644 --- a/psalm.xml +++ b/psalm.xml @@ -62,7 +62,6 @@ - diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index b4064c56a..11e977806 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -248,14 +248,6 @@ - - - - - - - - @@ -295,28 +287,6 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/stubs/oca_files_sharing_external_manager.php b/tests/stubs/oca_files_sharing_external_manager.php deleted file mode 100644 index 8f41c0c5c..000000000 --- a/tests/stubs/oca_files_sharing_external_manager.php +++ /dev/null @@ -1,157 +0,0 @@ - list of open server-to-server shares - */ - public function getOpenShares(): array - { - } - - /** - * Return a list of shares which are accepted by the user. - * - * @return list list of accepted server-to-server shares - */ - public function getAcceptedShares(): array - { - } -}