summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-04-28 14:25:17 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2021-04-29 09:21:08 +0200
commitc022e923ff19afe18b6af68b01fe8ca07c9891c0 (patch)
tree3e685fe2862edba8047c1b6deb6859a740a40ffd /lib/private
parent4369d1cf1d934b355ce53f025e22807774f64787 (diff)
downloadnextcloud-server-c022e923ff19afe18b6af68b01fe8ca07c9891c0.tar.gz
nextcloud-server-c022e923ff19afe18b6af68b01fe8ca07c9891c0.zip
Do not try to contact lookup server if not needed
In some cases (for example you never send data to the lookup server) there is no need for this job to even try. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Repair.php4
-rw-r--r--lib/private/Repair/NC22/LookupServerSendCheck.php63
2 files changed, 66 insertions, 1 deletions
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index b5e093765fd..16785396939 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -41,6 +41,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\NC11\FixMountStorages;
use OC\Repair\NC13\AddLogRotateJob;
use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
@@ -157,7 +158,8 @@ class Repair implements IOutput {
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
\OC::$server->query(ResetGeneratedAvatarFlag::class),
- \OC::$server->query(RepairDavShares::class)
+ \OC::$server->query(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..e6aa94c8a16
--- /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, '19.0.10.2', '<') &&
+ version_compare($versionFromBeforeUpdate, '19.0.0.0', '>');
+ }
+
+ public function run(IOutput $output): void {
+ $this->jobList->add(LookupServerSendCheckBackgroundJob::class);
+ }
+}