diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 6aba23fbd..662fb2cb9 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -118,7 +118,9 @@ class CoreRequestBuilder { 'token', 'parent', 'mountpoint', - 'mountpoint_hash' + 'mountpoint_hash', + 'remote', + 'remote_id', ], self::TABLE_MOUNTPOINT => [], self::TABLE_SHARE_LOCK => [], diff --git a/lib/Db/MountRequest.php b/lib/Db/MountRequest.php index eb1730cae..e77eabd1b 100644 --- a/lib/Db/MountRequest.php +++ b/lib/Db/MountRequest.php @@ -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 @@ -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(); } diff --git a/lib/Migration/Version0032Date20250623120204.php b/lib/Migration/Version0032Date20250623120204.php new file mode 100644 index 000000000..33fb6f322 --- /dev/null +++ b/lib/Migration/Version0032Date20250623120204.php @@ -0,0 +1,69 @@ +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; + } +} diff --git a/lib/Model/Mount.php b/lib/Model/Mount.php index 260072424..3d891454e 100644 --- a/lib/Model/Mount.php +++ b/lib/Model/Mount.php @@ -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; /** @@ -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 @@ -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()); } @@ -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);