Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions lib/Model/Mount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down
69 changes: 13 additions & 56 deletions lib/MountManager/CircleMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<IStorage> */
private string $storageClass;

/**
* CircleMount constructor.
*
* @param Mount $mount
* @param string $storage
* @param IStorageFactory|null $loader
* @param IStorage|class-string<IStorage> $storage
*
* @throws MountPointConstructionException
*/
public function __construct(
Mount $mount,
string $storage,
private Mount $mount,
IStorage|string $storage,
?IStorageFactory $loader = null,
) {
try {
Expand All @@ -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
*/
Expand Down
96 changes: 0 additions & 96 deletions lib/MountManager/CircleMountManager.php

This file was deleted.

82 changes: 2 additions & 80 deletions lib/MountManager/CircleMountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
class CircleMountProvider implements IMountProvider {
use TArrayTools;

/** @var class-string<ExternalStorage> */
public const EXTERNAL_STORAGE = ExternalStorage::class;

Check failure on line 45 in lib/MountManager/CircleMountProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/MountManager/CircleMountProvider.php:45:34: UndefinedClass: Class, interface or enum named OCA\Files_Sharing\External\Storage does not exist (see https://psalm.dev/019)

Check failure on line 45 in lib/MountManager/CircleMountProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidConstantAssignmentValue

lib/MountManager/CircleMountProvider.php:45:15: InvalidConstantAssignmentValue: OCA\Circles\MountManager\CircleMountProvider::EXTERNAL_STORAGE with declared type class-string<OCA\Files_Sharing\External\Storage> cannot be assigned type mixed (see https://psalm.dev/304)

Check failure on line 45 in lib/MountManager/CircleMountProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedDocblockClass

lib/MountManager/CircleMountProvider.php:45:2: UndefinedDocblockClass: Docblock-defined class, interface or enum named OCA\Files_Sharing\External\Storage does not exist (see https://psalm.dev/200)

public function __construct(
private IClientService $clientService,
private IRootFolder $rootFolder,
private CircleMountManager $circleMountManager,
private ICloudIdManager $cloudIdManager,
private MountRequest $mountRequest,
private MountPointRequest $mountPointRequest,
Expand All @@ -57,9 +57,6 @@
}

/**
* @param IUser $user
* @param IStorageFactory $loader
*
* @return list<IMountPoint>
* @throws RequestBuilderException
* @throws FederatedUserException
Expand All @@ -86,10 +83,6 @@


/**
* @param Mount $mount
* @param IStorageFactory $storageFactory
*
* @return CircleMount
* @throws InitiatorNotFoundException
* @throws MountPointConstructionException
*/
Expand All @@ -103,86 +96,15 @@
}

$mount->setCloudIdManager($this->cloudIdManager)
->setHttpClientService($this->clientService)
// ->setStorage(self::EXTERNAL_STORAGE)
->setMountManager($this->circleMountManager);
->setHttpClientService($this->clientService);

return new CircleMount(
$mount,
self::EXTERNAL_STORAGE,

Check failure on line 103 in lib/MountManager/CircleMountProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/MountManager/CircleMountProvider.php:103:4: InvalidArgument: Argument 2 of OCA\Circles\MountManager\CircleMount::__construct expects OCP\Files\Storage\IStorage|class-string<OCP\Files\Storage\IStorage>, but OCA\Files_Sharing\External\Storage::class provided (see https://psalm.dev/004)
$storageFactory
);
}


/**
* @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;
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<file name="tests/stubs/oca_dav_carddav_contactsmanager.php" />
<file name="tests/stubs/oca_federatedfilesharing_notifications.php" />
<file name="tests/stubs/oca_files_sharing_event_usershareaccessupdatedevent.php" />
<file name="tests/stubs/oca_files_sharing_external_manager.php" />
<file name="tests/stubs/oca_user_ldap_mapping_abstractmapping.php" />
<file name="tests/stubs/oca_user_ldap_mapping_usermapping.php" />
<file name="tests/stubs/stecman_component_symfony_console_bashcompletion_completion_completionawareinterface.php" />
Expand Down
Loading
Loading