diff options
author | Robin Appelman <robin@icewind.nl> | 2020-04-28 18:31:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 18:31:59 +0300 |
commit | 660b286c151fa6b7dc6b70cd938cc6f701a34889 (patch) | |
tree | 765379c72ef03c5f7236ca147dd3e342aa7e94f5 | |
parent | 444e96b8a757ea99aca1b36bb3bf45aec1e4549a (diff) | |
parent | 63628ab1395c6d59ddcd31442fedec9cdbac1e9e (diff) |
Merge pull request #113 from joequant/dev/flush-inactive-pages
add option to flush inactive pages / trap exceptions
-rw-r--r-- | lib/Command/FlushChanges.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/Command/FlushChanges.php b/lib/Command/FlushChanges.php index 13a79d1..4483afe 100644 --- a/lib/Command/FlushChanges.php +++ b/lib/Command/FlushChanges.php @@ -25,6 +25,7 @@ use OC\Core\Command\Base; use OCA\DocumentServer\Document\DocumentStore; use OCA\DocumentServer\Document\SaveHandler; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class FlushChanges extends Base { @@ -44,14 +45,27 @@ class FlushChanges extends Base { protected function configure() { $this ->setName('documentserver:flush') - ->setDescription('Flush all pending changes made to documents'); + ->setDescription('Flush all pending changes made to documents') + ->addOption( + 'inactive-pages', + null, + InputOption::VALUE_NONE, + 'Flush only inactive pages' + ); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output) { $documents = $this->documentStore->getOpenDocuments(); foreach ($documents as $documentId) { - $this->saveHandler->flushChanges($documentId); - } + if (!$input->getOption('inactive-pages') || + !$this->sessionManager->isDocumentActive($documentId)) { + try { + $this->saveHandler->flushChanges($documentId); + } catch (\Exception $e) { + $this->logger->logException($e, ['app' => 'documentserver_community', 'message' => 'Error while applying changes for document ' . $documentId]); + } + } + } } } |