Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2020-01-30 14:26:20 +0300
committerMaxence Lange <maxence@artificial-owl.com>2020-01-30 14:26:20 +0300
commit1021da368897a2357784db2771f1bdd2b5867f5f (patch)
tree6bfbafdfd846337a8e0cb297282f73e5f6b4129c
parenteada406b1537b2abeafc46b241d0caf934d3580b (diff)
1.3.7v1.3.7
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--CHANGELOG.md7
-rw-r--r--Makefile4
-rw-r--r--appinfo/info.xml5
-rw-r--r--lib/Command/DocumentStatus.php201
-rw-r--r--lib/Command/Live.php2
-rw-r--r--lib/Service/IndexService.php10
6 files changed, 223 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62d2c4d..08bdae8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+
+### 1.3.7
+
+- adding ./occ fulltextsearch:document:status
+- ability to set the index status to IGNORE
+
+
### 1.3.6
- some compat nc17
diff --git a/Makefile b/Makefile
index db758fd..cbc67de 100644
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,9 @@ sign_dir=$(build_dir)/sign
package_name=$(app_name)
cert_dir=$(HOME)/.nextcloud/certificates
github_account=nextcloud
-branch=master
+branch=stable16
codecov_token_dir=$(HOME)/.nextcloud/codecov_token
-version+=1.3.6
+version+=1.3.7
all: appstore
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 0126ecb..9b447cf 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -10,7 +10,7 @@ Core App of the full-text search framework for your Nextcloud.
]]>
</description>
- <version>1.3.6</version>
+ <version>1.3.7</version>
<licence>agpl</licence>
<author>Maxence Lange</author>
<namespace>FullTextSearch</namespace>
@@ -33,9 +33,10 @@ Core App of the full-text search framework for your Nextcloud.
<commands>
<command>OCA\FullTextSearch\Command\Check</command>
<command>OCA\FullTextSearch\Command\Configure</command>
- <command>OCA\FullTextSearch\Command\DocumentPlatform</command>
<command>OCA\FullTextSearch\Command\DocumentIndex</command>
+ <command>OCA\FullTextSearch\Command\DocumentPlatform</command>
<command>OCA\FullTextSearch\Command\DocumentProvider</command>
+ <command>OCA\FullTextSearch\Command\DocumentStatus</command>
<command>OCA\FullTextSearch\Command\Index</command>
<command>OCA\FullTextSearch\Command\Live</command>
<command>OCA\FullTextSearch\Command\Reset</command>
diff --git a/lib/Command/DocumentStatus.php b/lib/Command/DocumentStatus.php
new file mode 100644
index 0000000..d19915c
--- /dev/null
+++ b/lib/Command/DocumentStatus.php
@@ -0,0 +1,201 @@
+<?php declare(strict_types=1);
+
+
+/**
+ * FullTextSearch - Full text search framework for Nextcloud
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Maxence Lange <maxence@artificial-owl.com>
+ * @copyright 2018
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\FullTextSearch\Command;
+
+
+use Exception;
+use OC\Core\Command\Base;
+use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException;
+use OCA\FullTextSearch\Service\IndexService;
+use OCA\FullTextSearch\Service\MiscService;
+use OCP\FullTextSearch\Model\IIndex;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+
+/**
+ * Class DocumentStatus
+ *
+ * @package OCA\FullTextSearch\Command
+ */
+class DocumentStatus extends Base {
+
+
+ /** @var IndexService */
+ private $indexService;
+
+ /** @var MiscService */
+ private $miscService;
+
+ /** @var array */
+ private $statusAvailable = [
+ 'IGNORE' => 'document will never be indexed',
+ 'INDEX' => 'document will be indexed',
+ 'DONE' => 'document is well indexed',
+ 'REMOVE' => 'document will be removed',
+ 'FAILED' => 'index had fail'
+ ];
+
+
+ /**
+ * DocumentStatus constructor.
+ *
+ * @param IndexService $indexService
+ * @param MiscService $miscService
+ */
+ public function __construct(IndexService $indexService, MiscService $miscService) {
+ parent::__construct();
+
+ $this->indexService = $indexService;
+ $this->miscService = $miscService;
+ }
+
+
+ /**
+ *
+ */
+ protected function configure() {
+ parent::configure();
+ $this->setName('fulltextsearch:document:status')
+ ->setDescription('change the status on one specific document')
+ ->addArgument('provider', InputArgument::REQUIRED, 'Id of the provider')
+ ->addArgument('document', InputArgument::REQUIRED, 'If of the document')
+ ->addOption('value', '', InputOption::VALUE_REQUIRED, 'new status', '')
+ ->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'specify the owner of the document', '')
+ ->addOption('json', 'j', InputOption::VALUE_NONE, 'return status in JSON');
+ }
+
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @throws Exception
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $providerId = $input->getArgument('provider');
+ $documentId = $input->getArgument('document');
+ $value = $input->getOption('value');
+ $userId = $input->getOption('user');
+ $json = $input->getOption('json');
+
+ try {
+ $index = $this->indexService->getIndex($providerId, $documentId);
+ if ($value !== '') {
+ $status = $this->statusConvertFromString($value);
+ $index->setStatus($status, true);
+ $this->indexService->updateIndex($index);
+ }
+ } catch (IndexDoesNotExistException $e) {
+ if ($userId === '') {
+ throw new Exception(
+ "Index is not known.\nIf you want to generate the entry, please specify the owner of the document using --user <userId>"
+ );
+ }
+
+ $status = $this->statusConvertFromString($value);
+ $index = $this->indexService->createIndex($providerId, $documentId, $userId, $status);
+ }
+
+
+ if ($json) {
+ echo json_encode($index, JSON_PRETTY_PRINT) . "\n";
+
+ return;
+ }
+
+ $status = $this->statusConvertToString($index->getStatus());
+ $desc = $this->statusAvailable[$status];
+ $output->writeln('current status: <info>' . $status . '</info> (' . $desc . ')');
+ }
+
+
+ /**
+ * @param int $status
+ *
+ * @return string
+ */
+ private function statusConvertToString(int $status): string {
+ switch ($status) {
+ case IIndex::INDEX_OK:
+ case IIndex::INDEX_DONE:
+ return 'DONE';
+
+ case IIndex::INDEX_IGNORE:
+ return 'IGNORE';
+
+ case IIndex::INDEX_META:
+ case IIndex::INDEX_CONTENT:
+ case IIndex:: INDEX_PARTS:
+ case IIndex:: INDEX_FULL:
+ return 'INDEX';
+
+ case IIndex:: INDEX_REMOVE:
+ return 'REMOVE';
+
+ case IIndex::INDEX_FAILED:
+ return 'FAILED';
+ }
+
+ return 'unknown';
+ }
+
+
+ /**
+ * @param string $status
+ *
+ * @return int
+ * @throws Exception
+ */
+ private function statusConvertFromString(string $status): int {
+ switch ($status) {
+ case 'DONE':
+ return IIndex::INDEX_OK;
+
+ case 'IGNORE':
+ return IIndex::INDEX_IGNORE;
+
+ case 'INDEX':
+ return IIndex:: INDEX_FULL;
+
+ case 'REMOVE':
+ return IIndex:: INDEX_REMOVE;
+
+ case 'FAILED':
+ return IIndex::INDEX_FAILED;
+ }
+
+ throw new Exception("Specify a valid status: " . implode(', ', array_keys($this->statusAvailable)));
+ }
+
+}
+
diff --git a/lib/Command/Live.php b/lib/Command/Live.php
index 3d54d12..229c320 100644
--- a/lib/Command/Live.php
+++ b/lib/Command/Live.php
@@ -68,7 +68,7 @@ class Live extends ACommandBase {
const INDEX_OPTION_NO_READLINE = '_no-readline';
- const CYCLE_DELAY = 300000;
+ const CYCLE_DELAY = 3000000;
const PANEL_RUN = 'run';
const PANEL_RUN_LINE_MEMORY = 'Memory: %_memory%';
diff --git a/lib/Service/IndexService.php b/lib/Service/IndexService.php
index 3d1582b..b5a8f64 100644
--- a/lib/Service/IndexService.php
+++ b/lib/Service/IndexService.php
@@ -238,6 +238,10 @@ class IndexService implements IIndexService {
$index->setLastIndex();
}
+ if ($index->isStatus(Index::INDEX_IGNORE)) {
+ continue;
+ }
+
if ($options->getOption('errors', '') !== 'ignore' && $index->getErrorCount() > 0) {
continue;
}
@@ -398,6 +402,10 @@ class IndexService implements IIndexService {
]
);
+ if ($index->isStatus(IIndex::INDEX_IGNORE)) {
+ return;
+ }
+
if (!$index->isStatus(Index::INDEX_REMOVE)) {
try {
$document = $provider->updateDocument($index);
@@ -454,7 +462,7 @@ class IndexService implements IIndexService {
*
* @throws Exception
*/
- private function updateIndex(IIndex $index) {
+ public function updateIndex(IIndex $index) {
/** @var Index $index */
$this->updateIndexError($index);