blob: 6de143747b3e1a59db96c7e72b0dbaacf84e115e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Repair\NC20;
use OCP\Encryption\IManager;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class EncryptionMigration implements IRepairStep {
/** @var IConfig */
private $config;
/** @var IManager */
private $manager;
public function __construct(IConfig $config,
IManager $manager) {
$this->config = $config;
$this->manager = $manager;
}
public function getName(): string {
return 'Check encryption key format';
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=');
}
public function run(IOutput $output): void {
if (!$this->shouldRun()) {
return;
}
$masterKeyId = $this->config->getAppValue('encryption', 'masterKeyId');
if ($this->manager->isEnabled() || !empty($masterKeyId)) {
if ($this->config->getSystemValue('encryption.key_storage_migrated', '') === '') {
$this->config->setSystemValue('encryption.key_storage_migrated', false);
}
}
}
}
|