diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-04-29 16:49:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 16:49:19 +0300 |
commit | 7d9111dbc39090743c3ff208f2ca2d52f1977b71 (patch) | |
tree | 83277556910d3ff1b8ed7f284508cdc0bd3b5a08 | |
parent | 009b21268426dcf6bea7223b0186a08cce9dda4a (diff) | |
parent | f4135573d08d85843b68b6cc7e21257ab6b53db1 (diff) |
Merge pull request #26823 from nextcloud/backport/26811/stable21
[stable21] Do not try to contact lookup server if not needed
-rw-r--r-- | apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php | 12 | ||||
-rw-r--r-- | core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php | 51 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/private/Repair.php | 4 | ||||
-rw-r--r-- | lib/private/Repair/NC22/LookupServerSendCheck.php | 63 | ||||
-rw-r--r-- | version.php | 2 |
7 files changed, 133 insertions, 3 deletions
diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index c462eeedb43..da0721dc017 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -152,7 +152,14 @@ class RetryJob extends Job { try { if (count($data) === 1) { - // No public data, just the federation Id + $dataOnLookupServer = $this->config->getUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '0') === '1'; + + if (!$dataOnLookupServer) { + // We never send data to the lookupserver so no need to delete it + return; + } + + // There is data on the lookup server so we must delete it $client->delete($this->lookupServer, [ 'body' => json_encode($signedData), @@ -160,6 +167,8 @@ class RetryJob extends Job { 'connect_timeout' => 3, ] ); + + $this->config->setUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '0'); } else { $client->post($this->lookupServer, [ @@ -168,6 +177,7 @@ class RetryJob extends Job { 'connect_timeout' => 3, ] ); + $this->config->setUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '1'); } // Reset retry counter diff --git a/core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php b/core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php new file mode 100644 index 00000000000..c6bd3c1ea35 --- /dev/null +++ b/core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2021 Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Core\BackgroundJobs; + +use OC\BackgroundJob\QueuedJob; +use OCP\IConfig; +use OCP\IUser; +use OCP\IUserManager; + +class LookupServerSendCheckBackgroundJob extends QueuedJob { + + /** @var IConfig */ + protected $config; + /** @var IUserManager */ + private $userManager; + + public function __construct(IConfig $config, IUserManager $userManager) { + $this->config = $config; + $this->userManager = $userManager; + } + + public function run($arguments) { + $this->userManager->callForSeenUsers(function (IUser $user) { + $this->config->setUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '1'); + }); + } +} diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 85620b8a44e..e4708719660 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -793,6 +793,7 @@ return array( 'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => $baseDir . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php', 'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => $baseDir . '/core/BackgroundJobs/CheckForUserCertificates.php', 'OC\\Core\\BackgroundJobs\\CleanupLoginFlowV2' => $baseDir . '/core/BackgroundJobs/CleanupLoginFlowV2.php', + 'OC\\Core\\BackgroundJobs\\LookupServerSendCheckBackgroundJob' => $baseDir . '/core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php', 'OC\\Core\\Command\\App\\CheckCode' => $baseDir . '/core/Command/App/CheckCode.php', 'OC\\Core\\Command\\App\\Disable' => $baseDir . '/core/Command/App/Disable.php', 'OC\\Core\\Command\\App\\Enable' => $baseDir . '/core/Command/App/Enable.php', @@ -1305,6 +1306,7 @@ return array( 'OC\\Repair\\NC20\\ShippedDashboardEnable' => $baseDir . '/lib/private/Repair/NC20/ShippedDashboardEnable.php', 'OC\\Repair\\NC21\\AddCheckForUserCertificatesJob' => $baseDir . '/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php', 'OC\\Repair\\NC21\\ValidatePhoneNumber' => $baseDir . '/lib/private/Repair/NC21/ValidatePhoneNumber.php', + 'OC\\Repair\\NC22\\LookupServerSendCheck' => $baseDir . '/lib/private/Repair/NC22/LookupServerSendCheck.php', 'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\Owncloud\\CleanPreviews' => $baseDir . '/lib/private/Repair/Owncloud/CleanPreviews.php', 'OC\\Repair\\Owncloud\\CleanPreviewsBackgroundJob' => $baseDir . '/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 726a7338a7e..72d26d9c3d6 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -822,6 +822,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => __DIR__ . '/../../..' . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php', 'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => __DIR__ . '/../../..' . '/core/BackgroundJobs/CheckForUserCertificates.php', 'OC\\Core\\BackgroundJobs\\CleanupLoginFlowV2' => __DIR__ . '/../../..' . '/core/BackgroundJobs/CleanupLoginFlowV2.php', + 'OC\\Core\\BackgroundJobs\\LookupServerSendCheckBackgroundJob' => __DIR__ . '/../../..' . '/core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php', 'OC\\Core\\Command\\App\\CheckCode' => __DIR__ . '/../../..' . '/core/Command/App/CheckCode.php', 'OC\\Core\\Command\\App\\Disable' => __DIR__ . '/../../..' . '/core/Command/App/Disable.php', 'OC\\Core\\Command\\App\\Enable' => __DIR__ . '/../../..' . '/core/Command/App/Enable.php', @@ -1334,6 +1335,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Repair\\NC20\\ShippedDashboardEnable' => __DIR__ . '/../../..' . '/lib/private/Repair/NC20/ShippedDashboardEnable.php', 'OC\\Repair\\NC21\\AddCheckForUserCertificatesJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php', 'OC\\Repair\\NC21\\ValidatePhoneNumber' => __DIR__ . '/../../..' . '/lib/private/Repair/NC21/ValidatePhoneNumber.php', + 'OC\\Repair\\NC22\\LookupServerSendCheck' => __DIR__ . '/../../..' . '/lib/private/Repair/NC22/LookupServerSendCheck.php', 'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\Owncloud\\CleanPreviews' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/CleanPreviews.php', 'OC\\Repair\\Owncloud\\CleanPreviewsBackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php', diff --git a/lib/private/Repair.php b/lib/private/Repair.php index e7c6f729a8f..1fe332cf1e2 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -45,6 +45,7 @@ use OC\Repair\ClearFrontendCaches; use OC\Repair\ClearGeneratedAvatarCache; use OC\Repair\Collation; use OC\Repair\MoveUpdaterStepFile; +use OC\Repair\NC22\LookupServerSendCheck; use OC\Repair\Owncloud\CleanPreviews; use OC\Repair\NC11\FixMountStorages; use OC\Repair\Owncloud\MoveAvatars; @@ -190,7 +191,8 @@ class Repair implements IOutput { \OC::$server->get(ShippedDashboardEnable::class), \OC::$server->get(AddBruteForceCleanupJob::class), \OC::$server->get(AddCheckForUserCertificatesJob::class), - \OC::$server->get(RepairDavShares::class) + \OC::$server->get(RepairDavShares::class), + \OC::$server->get(LookupServerSendCheck::class), ]; } diff --git a/lib/private/Repair/NC22/LookupServerSendCheck.php b/lib/private/Repair/NC22/LookupServerSendCheck.php new file mode 100644 index 00000000000..6096fca0e11 --- /dev/null +++ b/lib/private/Repair/NC22/LookupServerSendCheck.php @@ -0,0 +1,63 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2021 Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Repair\NC22; + +use OC\Core\BackgroundJobs\LookupServerSendCheckBackgroundJob; +use OCP\BackgroundJob\IJobList; +use OCP\IConfig; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class LookupServerSendCheck implements IRepairStep { + + /** @var IJobList */ + private $jobList; + + /** @var IConfig */ + private $config; + + public function __construct(IJobList $jobList, IConfig $config) { + $this->jobList = $jobList; + $this->config = $config; + } + + public function getName(): string { + return 'Add background job to set the lookup server share state for users'; + } + + private function shouldRun(): bool { + $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + + // was added to 22.0.0.3 + return version_compare($versionFromBeforeUpdate, '21.0.1.2', '<') && + version_compare($versionFromBeforeUpdate, '21.0.0.0', '>'); + } + + public function run(IOutput $output): void { + $this->jobList->add(LookupServerSendCheckBackgroundJob::class); + } +} diff --git a/version.php b/version.php index 2be3f8af7bb..2bd364c5fe2 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [21, 0, 1, 1]; +$OC_Version = [21, 0, 1, 2]; // The human readable string $OC_VersionString = '21.0.1'; |