Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2021-01-26 12:26:10 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-03-18 10:59:45 +0300
commitec454e7c2ba342c246cd5b039eda3a269f99fe2c (patch)
treea5f37f96dcf187879732ec37fbf0f4b1975f92e9 /apps/files_sharing/lib
parent92daa942b0ada33c372ccc3bf6abe04066e2b6e2 (diff)
Fix valid storages removed when cleaning remote storages
The remote URL of a share is always stored in the database with a trailing slash. However, when a cloud ID is generated trailing slashes are removed. The ID of a remote storage is generated from the cloud ID, but the "cleanup-remote-storage" command directly used the remote URL stored in the database. Due to this, even if the remote storage was valid, its ID did not match the ID of the remote share generated by the command and ended being removed. Now the command generates the ID of remote shares using the cloud ID instead, just like done by the remote storage, so there is no longer a mismatch. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Command/CleanupRemoteStorages.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
index 259e55ff620..ab63df4559c 100644
--- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
+++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
@@ -25,6 +25,7 @@
namespace OCA\Files_Sharing\Command;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\Federation\ICloudIdManager;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -42,8 +43,14 @@ class CleanupRemoteStorages extends Command {
*/
protected $connection;
- public function __construct(IDBConnection $connection) {
+ /**
+ * @var ICloudIdManager
+ */
+ private $cloudIdManager;
+
+ public function __construct(IDBConnection $connection, ICloudIdManager $cloudIdManager) {
$this->connection = $connection;
+ $this->cloudIdManager = $cloudIdManager;
parent::__construct();
}
@@ -166,14 +173,17 @@ class CleanupRemoteStorages extends Command {
public function getRemoteShareIds() {
$queryBuilder = $this->connection->getQueryBuilder();
- $queryBuilder->select(['id', 'share_token', 'remote'])
+ $queryBuilder->select(['id', 'share_token', 'owner', 'remote'])
->from('share_external');
$query = $queryBuilder->execute();
$remoteShareIds = [];
while ($row = $query->fetch()) {
- $remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $row['remote']);
+ $cloudId = $this->cloudIdManager->getCloudId($row['owner'], $row['remote']);
+ $remote = $cloudId->getRemote();
+
+ $remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $remote);
}
return $remoteShareIds;