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:
authordaita <maxence@pontapreta.net>2016-11-06 13:35:13 +0300
committerdaita <maxence@pontapreta.net>2016-11-06 13:35:13 +0300
commitabbc15f93952fe6a0ed2c630cd130eb02cd6a7f0 (patch)
tree103d7c40418aecb8bb3df3a911bf784ae79be49a
parente69cfa67fa82c31c512e8019e29c13d2aa86e329 (diff)
ping first, then index
-rw-r--r--appinfo/register_command.php2
-rw-r--r--lib/Command/Index.php12
-rw-r--r--lib/Cron/BackgroundIndex.php8
3 files changed, 18 insertions, 4 deletions
diff --git a/appinfo/register_command.php b/appinfo/register_command.php
index 64bd025..843d857 100644
--- a/appinfo/register_command.php
+++ b/appinfo/register_command.php
@@ -29,7 +29,7 @@ $c = $app->getContainer();
$application->add(new OCA\Nextant\Command\Check($c->query('SolrService'), $c->query('SolrToolsService'), $c->query('SolrAdminService')));
$application->add(new OCA\Nextant\Command\Clear($c->query('ConfigService'), $c->query('SolrService'), $c->query('SolrAdminService')));
-$application->add(new OCA\Nextant\Command\Index(OC::$server->getUserManager(), $c->query('RootFolder'), $c->query('IndexService'), $c->query('QueueService'), $c->query('SolrService'), $c->query('ConfigService'), $c->query('FileService'), $c->query('BookmarkService'), $c->query('MiscService')));
+$application->add(new OCA\Nextant\Command\Index(OC::$server->getUserManager(), $c->query('RootFolder'), $c->query('IndexService'), $c->query('QueueService'), $c->query('SolrService'), $c->query('SolrAdminService'), $c->query('ConfigService'), $c->query('FileService'), $c->query('BookmarkService'), $c->query('MiscService')));
$application->add(new OCA\Nextant\Command\Optimize($c->query('SolrService'), $c->query('SolrToolsService')));
$application->add(new OCA\Nextant\Command\Live($c->query('QueueService'), $c->query('IndexService'), $c->query('SolrService'), $c->query('SolrToolsService'), $c->query('ConfigService'), $c->query('FileService'), $c->query('BookmarkService'), $c->query('MiscService')));
diff --git a/lib/Command/Index.php b/lib/Command/Index.php
index 88ea201..06c0a8d 100644
--- a/lib/Command/Index.php
+++ b/lib/Command/Index.php
@@ -52,6 +52,8 @@ class Index extends Base
private $solrService;
+ private $solrAdmin;
+
private $configService;
private $fileService;
@@ -62,7 +64,7 @@ class Index extends Base
private $currentIndexStatus = array();
- public function __construct(IUserManager $userManager, $rootFolder, $indexService, $queueService, $solrService, $configService, $fileService, $bookmarkService, $miscService)
+ public function __construct(IUserManager $userManager, $rootFolder, $indexService, $queueService, $solrService, $solrAdmin, $configService, $fileService, $bookmarkService, $miscService)
{
parent::__construct();
$this->userManager = $userManager;
@@ -70,6 +72,7 @@ class Index extends Base
$this->indexService = $indexService;
$this->queueService = $queueService;
$this->solrService = $solrService;
+ $this->solrAdmin = $solrAdmin;
$this->configService = $configService;
$this->fileService = $fileService;
$this->bookmarkService = $bookmarkService;
@@ -161,6 +164,11 @@ class Index extends Base
return;
}
+ if (! ($this->solrAdmin->ping())) {
+ $output->writeln('*** Solr seems down.');
+ return false;
+ }
+
$this->indexService->lockActive(true);
$this->configService->lockIndex(true);
@@ -364,7 +372,7 @@ class Index extends Base
$this->indexService->extract(ItemDocument::TYPE_BOOKMARK, $user, $bm, $solrDocs);
$this->indexService->removeOrphans(ItemDocument::TYPE_BOOKMARK, $user, $bm, $solrDocs);
- foreach ($files as $doc) {
+ foreach ($bm as $doc) {
if ($doc->isIndexed())
$indexed ++;
if ($doc->isExtracted())
diff --git a/lib/Cron/BackgroundIndex.php b/lib/Cron/BackgroundIndex.php
index 5d8bacf..848829b 100644
--- a/lib/Cron/BackgroundIndex.php
+++ b/lib/Cron/BackgroundIndex.php
@@ -35,6 +35,8 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
private $configService;
+ private $solrAdmin;
+
private $miscService;
public function __construct()
@@ -52,6 +54,7 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
$this->userManager = $c->query('UserManager');
$this->solrService = $c->query('SolrService');
$this->solrTools = $c->query('SolrToolsService');
+ $this->solrAdmin = $c->query('SolrAdminService');
$this->fileService = $c->query('FileService');
$this->indexService = $c->query('IndexService');
$this->bookmarkService = $c->query('BookmarkService');
@@ -61,10 +64,13 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
if (! $this->solrService->configured(false))
return;
+ if (! $this->solrAdmin->ping())
+ return;
+
if ($this->configService->isLockedIndex())
return;
- $this->indexService->lockActive(true);
+ $this->indexService->lockActive(true);
$this->configService->lockIndex(true);
$this->liveIndex();