Skip to content
Merged
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
4 changes: 3 additions & 1 deletion lib/Db/CoreRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ class CoreRequestBuilder {
'token',
'parent',
'mountpoint',
'mountpoint_hash'
'mountpoint_hash',
'remote',
'remote_id',
],
self::TABLE_MOUNTPOINT => [],
self::TABLE_SHARE_LOCK => [],
Expand Down
5 changes: 4 additions & 1 deletion lib/Db/MountRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCA\Circles\IFederatedUser;
use OCA\Circles\Model\Mount;
use OCA\Circles\Tools\Traits\TStringTools;
use OCP\DB\QueryBuilder\IQueryBuilder;

/**
* Class MountRequest
Expand All @@ -36,7 +37,9 @@ public function save(Mount $mount): void {
->setValue('token', $qb->createNamedParameter($mount->getToken()))
->setValue('parent', $qb->createNamedParameter($mount->getParent()))
->setValue('mountpoint', $qb->createNamedParameter($mount->getOriginalMountPoint()))
->setValue('mountpoint_hash', $qb->createNamedParameter(md5($mount->getOriginalMountPoint())));
->setValue('mountpoint_hash', $qb->createNamedParameter(md5($mount->getOriginalMountPoint())))
->setValue('remote', $qb->createNamedParameter($mount->getRemote()))
->setValue('remote_id', $qb->createNamedParameter($mount->getRemoteShareId(), IQueryBuilder::PARAM_INT));

$qb->execute();
}
Expand Down
69 changes: 69 additions & 0 deletions lib/Migration/Version0032Date20250623120204.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);


/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


namespace OCA\Circles\Migration;

use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\Attributes\AddColumn;
use OCP\Migration\Attributes\ColumnType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Psr\Log\LoggerInterface;

#[AddColumn('circles_mount', 'remote', ColumnType::STRING, 'store remote instance for quicker identification')]
#[AddColumn('circles_mount', 'remote_id', ColumnType::INTEGER, 'store remote share id for quicker identification')]
class Version0032Date20250623120204 extends SimpleMigrationStep {
public function __construct(
private LoggerInterface $logger,
) {
}

public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

try {
$table = $schema->getTable('circles_mount');
if (!$table->hasColumn('remote')) {
$table->addColumn(
'remote', 'string',
[
'length' => 255,
'notnull' => false,
'default' => '',
]
);
}
if (!$table->hasColumn('remote_id')) {
$table->addColumn(
'remote_id', 'integer',
[
'length' => 20,
'unsigned' => true,
'notnull' => true,
'default' => 0,
]
);
}

if (!$table->hasIndex('m_sid_rmt_rid')) {
$table->addIndex(['circle_id', 'remote', 'remote_id'], 'm_sid_rmt_rid');
}
} catch (SchemaException $e) {
$this->logger->warning('Could not find circles_mount', ['exception' => $e]);
return null;
}

return $schema;
}
}
37 changes: 19 additions & 18 deletions lib/Model/Mount.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Mount extends ManagedModel implements IDeserializable, IQueryRow, JsonSeri
private ICloudIdManager $cloudIdManager;
private IClientService $httpClientService;
private CircleMountManager $mountManager;
private string $remote = '';
private int $remoteShareId = 0;


/**
Expand Down Expand Up @@ -323,26 +325,21 @@ public function getMountManager(): CircleMountManager {
return $this->mountManager;
}

public function setRemote(string $remote): void {
$this->remote = $remote;
}

//
// /**
// * @param string $storage
// *
// * @return Mount
// */
// public function setStorage(string $storage): self {
// $this->storage = $storage;
//
// return $this;
// }
//
// /**
// * @return string
// */
// public function getStorage(): string {
// return $this->storage;
// }
public function getRemote(): string {
return $this->remote;
}

public function setRemoteShareId(int $remoteShareId): void {
$this->remoteShareId = $remoteShareId;
}

public function getRemoteShareId(): int {
return $this->remoteShareId;
}

/**
* @return array
Expand Down Expand Up @@ -384,6 +381,8 @@ public function fromShare(ShareWrapper $wrappedShare) {
$this->setParent(-1);
$this->setOriginalMountPoint($wrappedShare->getFileTarget());
$this->setOriginalMountPointHash(md5($wrappedShare->getFileTarget()));
$this->setRemote($wrappedShare->getOwner()->getInstance());
$this->setRemoteShareId((int)$wrappedShare->getId());
}


Expand Down Expand Up @@ -411,6 +410,8 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow
$this->setOriginalMountPoint($this->get('mountpoint', $data));
$this->setOriginalMountPointHash($this->get('mountpoint_hash', $data));
$this->setMountId($this->get('mount_id', $data));
$this->setRemote($this->get('remote', $data));
$this->setRemoteShareId($this->getInt('remote_id', $data));

$this->getManager()->manageImportFromDatabase($this, $data, $prefix);

Expand Down
Loading