1
0

EncryptionLegacyCipher.php 1.2 KB

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