diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-07-13 19:24:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-13 19:24:47 +0300 |
commit | fed34943cf4e2f7e4a51af9dd86652560e729290 (patch) | |
tree | 82abfec701d9ff50e1a85653867e80241896c12b | |
parent | d0ff465b030d206fb6ef8232357ce8337e93b88e (diff) | |
parent | 7b8c84754a2db5c6bcb46c361fe0c8ee244a9571 (diff) |
Merge pull request #527 from nextcloud/bugfix/noid/empty-json-means-empty-array
use getArray to parse imported json
-rw-r--r-- | lib/Command/Live.php | 53 | ||||
-rw-r--r-- | lib/Db/IndexesRequestBuilder.php | 2 |
2 files changed, 38 insertions, 17 deletions
diff --git a/lib/Command/Live.php b/lib/Command/Live.php index c5bfb3c..3d54d12 100644 --- a/lib/Command/Live.php +++ b/lib/Command/Live.php @@ -198,6 +198,10 @@ class Live extends ACommandBase { ->addOption( 'no-readline', 'r', InputOption::VALUE_NONE, 'disable readline - non interactive mode' + ) + ->addOption( + 'service', 's', InputOption::VALUE_NONE, + 'disable interface' ); } @@ -215,7 +219,8 @@ class Live extends ACommandBase { throw new Exception('This feature is only available on Nextcloud 14 or newer'); } - if (!$input->getOption('no-readline')) { + + if (!$input->getOption('service') && !$input->getOption('no-readline')) { try { /** do not get stuck while waiting interactive input */ readline_callback_handler_install( @@ -235,31 +240,47 @@ class Live extends ACommandBase { ->setStyle('char', $outputStyle); $this->runner = new Runner($this->runningService, 'commandIndex', ['nextStep' => 'n']); - $this->runner->onKeyPress([$this, 'onKeyPressed']); - $this->runner->onNewIndexError([$this, 'onNewIndexError']); - $this->runner->onNewIndexResult([$this, 'onNewIndexResult']); + if (!$input->getOption('service')) { + $this->runner->onKeyPress([$this, 'onKeyPressed']); + $this->runner->onNewIndexError([$this, 'onNewIndexError']); + $this->runner->onNewIndexResult([$this, 'onNewIndexResult']); + $this->runner->sourceIsCommandLine($this, $output); + + $this->generatePanels(!$input->getOption('no-readline')); + } $this->indexService->setRunner($this->runner); $this->cliService->setRunner($this->runner); - $this->generatePanels(!$input->getOption('no-readline')); + while (true) { + try { + $this->runner->start(); + + if (!$input->getOption('service')) { + $this->cliService->runDisplay($output); + $this->generateIndexErrors(); + $this->displayError(); + $this->displayResult(); + } + $this->liveCycle(); - try { - $this->runner->sourceIsCommandLine($this, $output); - $this->runner->start(); + } catch (Exception $e) { + $this->miscService->log( + 'Exception while live index: ' . get_class($e) . ' - ' . $e->getMessage() + ); - $this->cliService->runDisplay($output); - $this->generateIndexErrors(); - $this->displayError(); - $this->displayResult(); + if (!$input->getOption('service')) { + throw $e; + } + } - $this->liveCycle(); + if (!$input->getOption('service')) { + break; + } - } catch (Exception $e) { - $this->runner->exception($e->getMessage(), true); - throw $e; + sleep(120); } $this->runner->stop(); diff --git a/lib/Db/IndexesRequestBuilder.php b/lib/Db/IndexesRequestBuilder.php index 0fb32f4..5b21a8f 100644 --- a/lib/Db/IndexesRequestBuilder.php +++ b/lib/Db/IndexesRequestBuilder.php @@ -120,7 +120,7 @@ class IndexesRequestBuilder extends CoreRequestBuilder { ->setSource($this->get('source', $data, '')) ->setOwnerId($this->get('owner_id', $data, '')) ->setLastIndex($this->getInt('indexed', $data, 0)); - $index->setOptions(json_decode($data['options'], true)); + $index->setOptions($this->getArray('options', $data, [])); $index->setErrorCount($this->getInt('err', $data, 0)); $index->setErrors(json_decode($data['message'], true)); |