Skip to content

Commit 329a696

Browse files
committed
manual maintenance mode
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 526011c commit 329a696

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

lib/Command/PointRestore.php

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
250250
}
251251

252252
$output->writeln('');
253-
$output->writeln(' > Enabling <info>maintenance mode</info>');
253+
$output->writeln('> Enabling <info>maintenance mode</info>');
254254
$this->configService->maintenanceMode(true);
255255
$this->restorePointComplete($point);
256256

257257
$this->output->writeln('');
258258
$this->updateConfig($point);
259259

260260
$output->writeln('> Finalization of the restoring process');
261+
$output->writeln('> <info>maintenance mode</info> disabled');
261262
$this->restoreService->finalizeFullRestore();
262263

263-
$output->writeln('> Disabling <info>maintenance mode</info>');
264-
$this->configService->maintenanceMode(false);
264+
// $this->configService->maintenanceMode(false);
265265

266266
$this->activityService->newActivity(
267267
ActivityService::RESTORE,
@@ -502,28 +502,25 @@ private function updateConfig(RestoringPoint $point): void {
502502
$configFile = rtrim($configRoot, '/') . '/config.php';
503503
include $configFile;
504504

505-
$updated = false;
506-
$this->compareConfigDataRoot($CONFIG, $dataRoot, $updated);
507-
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_HOST, $updated);
508-
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_PORT, $updated);
509-
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_NAME, $updated);
510-
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_USER, $updated);
511-
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_PASS, $updated);
505+
$this->compareConfigDataRoot($CONFIG, $dataRoot);
506+
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_HOST);
507+
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_PORT);
508+
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_NAME);
509+
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_USER);
510+
$this->compareConfigSqlParams($sqlParams, $CONFIG, ISqlDump::DB_PASS);
512511

513-
if ($updated) {
514-
$this->output->writeln(' > Updating <info>config.php</info>');
515-
$this->output->writeln('');
516-
file_put_contents($configFile, '<?php ' . "\n" . '$CONFIG = ' . var_export($CONFIG, true) . ';');
517-
}
512+
$CONFIG['maintenance'] = false;
513+
$this->output->writeln(' > Updating <info>config.php</info>');
514+
$this->output->writeln('');
515+
file_put_contents($configFile, '<?php ' . "\n" . '$CONFIG = ' . var_export($CONFIG, true) . ';');
518516
}
519517

520518

521519
/**
522520
* @param array $CONFIG
523521
* @param string $used
524-
* @param bool $updated
525522
*/
526-
private function compareConfigDataRoot(array &$CONFIG, string $used, bool &$updated): void {
523+
private function compareConfigDataRoot(array &$CONFIG, string $used): void {
527524
$fromConfig = rtrim($this->get(ConfigService::DATA_DIRECTORY, $CONFIG), '/') . '/';
528525

529526
if ($fromConfig !== $used) {
@@ -544,7 +541,6 @@ private function compareConfigDataRoot(array &$CONFIG, string $used, bool &$upda
544541
$helper = $this->getHelper('question');
545542
if ($helper->ask($this->input, $this->output, $question)) {
546543
$CONFIG[ConfigService::DATA_DIRECTORY] = $used;
547-
$updated = true;
548544
}
549545
}
550546
}
@@ -554,14 +550,8 @@ private function compareConfigDataRoot(array &$CONFIG, string $used, bool &$upda
554550
* @param array $sqlParams
555551
* @param array $CONFIG
556552
* @param string $key
557-
* @param bool $updated
558553
*/
559-
private function compareConfigSqlParams(
560-
array $sqlParams,
561-
array &$CONFIG,
562-
string $key,
563-
bool &$updated
564-
): void {
554+
private function compareConfigSqlParams(array $sqlParams, array &$CONFIG, string $key): void {
565555
$fromConfig = $this->get($key, $CONFIG);
566556
$used = $this->get($key, $sqlParams);
567557
if ($used !== $fromConfig) {
@@ -591,7 +581,6 @@ private function compareConfigSqlParams(
591581
$helper = $this->getHelper('question');
592582
if ($helper->ask($this->input, $this->output, $question)) {
593583
$CONFIG[$key] = $used;
594-
$updated = true;
595584
}
596585
}
597586
}

lib/Command/PointUpload.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use OC\Core\Command\Base;
3535
use OCA\Backup\Exceptions\ExternalFolderNotFoundException;
3636
use OCA\Backup\Exceptions\RemoteInstanceNotFoundException;
37+
use OCA\Backup\Exceptions\RestoringPointLockException;
3738
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
3839
use OCA\Backup\Exceptions\RestoringPointPackException;
3940
use OCA\Backup\Service\OutputService;
@@ -104,17 +105,21 @@ protected function configure() {
104105
* @param InputInterface $input
105106
* @param OutputInterface $output
106107
*
108+
* @return int
109+
* @throws ExternalFolderNotFoundException
107110
* @throws NotFoundException
108111
* @throws NotPermittedException
109112
* @throws RemoteInstanceNotFoundException
110113
* @throws RestoringPointNotFoundException
111-
* @throws ExternalFolderNotFoundException
112114
* @throws RestoringPointPackException
115+
* @throws RestoringPointLockException
113116
*/
114-
protected function execute(InputInterface $input, OutputInterface $output) {
117+
protected function execute(InputInterface $input, OutputInterface $output): int {
115118
$point = $this->pointService->getLocalRestoringPoint($input->getArgument('point'));
116119

117120
$this->outputService->setOutput($output);
118121
$this->uploadService->uploadPoint($point);
122+
123+
return 0;
119124
}
120125
}

0 commit comments

Comments
 (0)