|
9 | 9 | namespace OC\Core\Command\Encryption; |
10 | 10 |
|
11 | 11 | use OCP\App\IAppManager; |
12 | | -use OCP\Exceptions\AppConfigTypeConflictException; |
13 | 12 | use OCP\IAppConfig; |
14 | 13 | use OCP\IConfig; |
15 | 14 | use Symfony\Component\Console\Command\Command; |
@@ -92,16 +91,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
92 | 91 | return 1; |
93 | 92 | } |
94 | 93 |
|
95 | | - try { |
96 | | - $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); |
97 | | - } catch (AppConfigTypeConflictException) { |
98 | | - $raw = $this->appConfig->getValueString('core', 'encryption_enabled', 'no'); |
99 | | - $originallyEnabled = in_array(strtolower(trim($raw)), ['1', 'true', 'yes', 'on'], true); |
100 | | - } |
| 94 | + $originallyEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled', false); |
101 | 95 | try { |
102 | 96 | if ($originallyEnabled) { |
103 | 97 | $output->write('Disable server side encryption... '); |
104 | | - $this->writeEncryptionEnabled(false); |
| 98 | + $this->appConfig->setValueBool('core', 'encryption_enabled', false); |
105 | 99 | $output->writeln('done.'); |
106 | 100 | } else { |
107 | 101 | $output->writeln('Server side encryption not enabled. Nothing to do.'); |
@@ -129,37 +123,29 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
129 | 123 | $output->writeln(' aborted.'); |
130 | 124 | if ($originallyEnabled) { |
131 | 125 | $output->writeln('Server side encryption remains enabled'); |
132 | | - $this->writeEncryptionEnabled(true); |
| 126 | + $this->appConfig->setValueBool('core', 'encryption_enabled', true); |
133 | 127 | } |
134 | 128 | } elseif (($uid !== '') && $originallyEnabled) { |
135 | 129 | $output->writeln('Server side encryption remains enabled'); |
136 | | - $this->writeEncryptionEnabled(true); |
| 130 | + $this->appConfig->setValueBool('core', 'encryption_enabled', true); |
137 | 131 | } |
138 | 132 | $this->resetMaintenanceAndTrashbin(); |
139 | 133 | return 0; |
140 | 134 | } |
141 | 135 | if ($originallyEnabled) { |
142 | 136 | $output->write('Enable server side encryption... '); |
143 | | - $this->writeEncryptionEnabled(true); |
| 137 | + $this->appConfig->setValueBool('core', 'encryption_enabled', true); |
144 | 138 | $output->writeln('done.'); |
145 | 139 | } |
146 | 140 | $output->writeln('aborted'); |
147 | 141 | return 1; |
148 | 142 | } catch (\Exception $e) { |
149 | 143 | // enable server side encryption again if something went wrong |
150 | 144 | if ($originallyEnabled) { |
151 | | - $this->writeEncryptionEnabled(true); |
| 145 | + $this->appConfig->setValueBool('core', 'encryption_enabled', true); |
152 | 146 | } |
153 | 147 | $this->resetMaintenanceAndTrashbin(); |
154 | 148 | throw $e; |
155 | 149 | } |
156 | 150 | } |
157 | | - |
158 | | - private function writeEncryptionEnabled(bool $enabled): void { |
159 | | - try { |
160 | | - $this->appConfig->setValueBool('core', 'encryption_enabled', $enabled); |
161 | | - } catch (AppConfigTypeConflictException) { |
162 | | - $this->appConfig->setValueString('core', 'encryption_enabled', $enabled ? 'yes' : 'no'); |
163 | | - } |
164 | | - } |
165 | 151 | } |
0 commit comments