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:
-rw-r--r--js/settings.admin.js80
-rw-r--r--lib/Command/Index.php22
-rw-r--r--lib/Controller/SettingsController.php32
-rw-r--r--lib/Cron/BackgroundIndex.php12
-rw-r--r--lib/Events/FilesEvents.php36
-rw-r--r--lib/Service/ConfigService.php57
-rw-r--r--lib/Service/FileService.php10
-rw-r--r--lib/Service/SolrAdminService.php2
-rw-r--r--templates/settings.admin.php19
9 files changed, 150 insertions, 120 deletions
diff --git a/js/settings.admin.js b/js/settings.admin.js
index 2959f2f..1333668 100644
--- a/js/settings.admin.js
+++ b/js/settings.admin.js
@@ -38,31 +38,32 @@ $(document)
savesuboptions : function(switched) {
- var needed_index = -1;
+ var index_files_needed = -1;
if (switched == 'force_index')
- needed_index = 1;
+ index_files_needed = 1;
var data = {
- live_extract : ($('#solr_live_extract')
+ index_files_live_extract : ($('#solr_index_files_live_extract')
.is(':checked')) ? 1 : 0,
- live_docupdate : ($('#solr_live_docupdate')
+ index_files_live_update : ($('#solr_index_files_live_update')
.is(':checked')) ? 1 : 0,
- max_size : $('#solr_max_size').val(),
- external_index : ($('#solr_external_index')
+ index_files_max_size : $(
+ '#solr_index_files_max_size').val(),
+ index_files_external_index : ($('#solr_index_files_external_index')
.is(':checked')) ? 1 : 0,
display_result : $('#solr_display_result')
.val(),
- needed_index : needed_index
+ index_files_needed : index_files_needed
}
- if (switched == 'live_extract')
- data.live_extract = (data.live_extract == 1) ? 0
+ if (switched == 'index_files_live_extract')
+ data.index_files_live_extract = (data.index_files_live_extract == 1) ? 0
: 1;
- if (switched == 'live_docupdate')
- data.live_docupdate = (data.live_docupdate == 1) ? 0
+ if (switched == 'index_files_live_update')
+ data.index_files_live_update = (data.index_files_live_update == 1) ? 0
: 1;
- if (switched == 'external_index')
- data.external_index = (data.external_index == 1) ? 0
+ if (switched == 'index_files_external_index')
+ data.index_files_external_index = (data.index_files_external_index == 1) ? 0
: 1;
$.post(OC.filePath('nextant', 'ajax/settings',
@@ -102,20 +103,21 @@ $(document)
$('#nextant_suboptions').fadeTo(delay, 0.4);
}
- $('#solr_live_extract').prop('checked',
- (response.live_extract == 1));
- $('#solr_live_docupdate').prop('checked',
- (response.live_docupdate == 1));
- $('#solr_external_index').prop('checked',
- (response.external_index == 1));
+ $('#solr_index_files_live_extract').prop('checked',
+ (response.index_files_live_extract == 1));
+ $('#solr_index_files_live_update').prop('checked',
+ (response.index_files_live_update == 1));
+ $('#solr_index_files_external_index').prop('checked',
+ (response.index_files_external_index == 1));
- if (response.last_index > 0)
- $('#solr_last_index').text(
- response.last_index_format);
+ if (response.index_files_last > 0)
+ $('#solr_index_files_last').text(
+ response.index_files_last_format);
else
- $('#solr_last_index').text('never');
+ $('#solr_index_files_last').text('never');
- $('#solr_max_size').val(response.max_size);
+ $('#solr_index_files_max_size').val(
+ response.index_files_max_size);
$(
'#solr_display_result option[value="'
@@ -131,17 +133,17 @@ $(document)
$('#solr_current_docs').text(
'Solr Core is down');
else {
- if (response.solr_lock > 0) {
+ if (response.index_locked > 0) {
$('#nextant_first_index').hide(delay);
$('#nextant_index_scheduled').hide(delay);
$('#nextant_force_index').hide(delay);
$('#nextant_index_inprogress').show(delay);
- } else if (response.needed_index == 2) {
+ } else if (response.index_files_needed == 2) {
$('#nextant_first_index').show(delay);
$('#nextant_index_scheduled').hide(delay);
$('#nextant_force_index').hide(delay);
$('#nextant_index_inprogress').hide(delay);
- } else if (response.needed_index == 1) {
+ } else if (response.index_files_needed == 1) {
$('#nextant_first_index').hide(delay);
$('#nextant_force_index').hide(delay);
$('#nextant_index_scheduled').show(delay);
@@ -343,17 +345,23 @@ $(document)
$('#nextant_apply').on('click', nextantSettings.save);
- $('#solr_live_extract').mousedown(function() {
- nextantSettings.savesuboptions('live_extract');
- });
- $('#solr_live_docupdate').mousedown(function() {
- nextantSettings.savesuboptions('live_docupdate');
- });
- $('#solr_max_size').on('input', function(e) {
+ $('#solr_index_files_live_extract')
+ .mousedown(
+ function() {
+ nextantSettings
+ .savesuboptions('index_files_live_extract');
+ });
+ $('#solr_index_files_live_update')
+ .mousedown(
+ function() {
+ nextantSettings
+ .savesuboptions('index_files_live_update');
+ });
+ $('#solr_index_files_max_size').on('input', function(e) {
nextantSettings.savesuboptions();
});
- $('#solr_external_index').mousedown(function() {
- nextantSettings.savesuboptions('external_index');
+ $('#solr_index_files_external_index').mousedown(function() {
+ nextantSettings.savesuboptions('index_files_external_index');
});
$('#nextant_force_index').on('click', function() {
nextantSettings.savesuboptions('force_index');
diff --git a/lib/Command/Index.php b/lib/Command/Index.php
index 49de5be..f62360b 100644
--- a/lib/Command/Index.php
+++ b/lib/Command/Index.php
@@ -105,20 +105,20 @@ class Index extends Base
}
if ($input->getOption('background')) {
- $this->configService->needIndex(true, ($input->getOption('force')));
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->needIndexFiles(true, ($input->getOption('force')));
+ $this->configService->setAppValue('index_locked', '0');
$output->writeln('An indexing process will start as a background process within the next few hours');
return;
}
- $solr_locked = $this->configService->getAppValue('solr_lock');
+ $solr_locked = $this->configService->getAppValue('index_locked');
if (! $input->getOption('force') && ($solr_locked > (time() - (3600 * 24)))) {
$output->writeln('Your solr is locked by a running script like an index command or background jobs (cron)');
$output->writeln('You can still use the --force');
return;
}
- $this->configService->setAppValue('solr_lock', time());
+ $this->configService->setAppValue('index_locked', time());
$documentIds = array();
@@ -207,14 +207,14 @@ class Index extends Base
$this->removeOrphans($output, $documentIds);
- $this->configService->needIndex(false);
+ $this->configService->needIndexFiles(false);
if ($noFailure)
- $this->configService->setAppValue('last_index', time());
+ $this->configService->setAppValue('index_files_last', time());
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->setAppValue('index_locked', '0');
$output->writeln('');
}
@@ -256,7 +256,7 @@ class Index extends Base
$this->miscService->debug('(' . $userId . ') - scanning file #' . $file->getId() . ' (' . $file->getMimeType() . ') ' . $file->getPath());
if ($this->hasBeenInterrupted()) {
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->setAppValue('index_locked', '0');
throw new \Exception('ctrl-c');
}
@@ -328,7 +328,7 @@ class Index extends Base
while ($file = array_shift($fileIds)) {
if ($this->hasBeenInterrupted()) {
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->setAppValue('index_locked', '0');
throw new \Exception('ctrl-c');
}
@@ -390,7 +390,7 @@ class Index extends Base
while (true) {
if ($this->hasBeenInterrupted()) {
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->setAppValue('index_locked', '0');
throw new \Exception('ctrl-c');
}
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index de0d5d2..1839745 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -74,7 +74,7 @@ class SettingsController extends Controller
public function forceIndex()
{
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
public function updateSubOptions($instant)
@@ -85,31 +85,31 @@ class SettingsController extends Controller
'ping' => $this->solrAdmin->ping($error),
'nextant_version' => $this->configService->getAppValue('installed_version') . ' (beta)',
'current_docs' => $this->solrTools->count('files', $error),
- 'last_index' => $this->configService->getAppValue('last_index'),
- 'last_index_format' => date('r', $this->configService->getAppValue('last_index')),
- 'needed_index' => $this->configService->getAppValue('needed_index'),
- 'max_size' => $this->configService->getAppValue('max_size'),
+ 'index_files_last' => $this->configService->getAppValue('index_files_last'),
+ 'index_files_last_format' => date('r', $this->configService->getAppValue('index_files_last')),
+ 'index_files_needed' => $this->configService->getAppValue('index_files_needed'),
+ 'index_files_max_size' => $this->configService->getAppValue('index_files_max_size'),
'display_result' => $this->configService->getAppValue('display_result'),
- 'live_extract' => $this->configService->getAppValue('live_extract'),
- 'live_docupdate' => $this->configService->getAppValue('live_docupdate'),
- 'external_index' => $this->configService->getAppValue('external_index'),
+ 'index_files_live_extract' => $this->configService->getAppValue('index_files_live_extract'),
+ 'index_files_live_update' => $this->configService->getAppValue('index_files_live_update'),
+ 'index_files_external_index' => $this->configService->getAppValue('index_files_external_index'),
'solr_url' => $this->configService->getAppValue('solr_url'),
'solr_core' => $this->configService->getAppValue('solr_core'),
- 'solr_lock' => $this->configService->getAppValue('solr_lock')
+ 'index_locked' => $this->configService->getAppValue('index_locked')
);
return $response;
}
- public function setOptions($live_extract, $live_docupdate, $max_size, $external_index, $display_result, $needed_index)
+ public function setOptions($index_files_live_extract, $index_files_live_update, $index_files_max_size, $index_files_external_index, $display_result, $index_files_needed)
{
- $this->configService->setAppValue('live_extract', $live_extract);
- $this->configService->setAppValue('live_docupdate', $live_docupdate);
- $this->configService->setAppValue('external_index', $external_index);
- $this->configService->setAppValue('max_size', $max_size);
+ $this->configService->setAppValue('index_files_live_extract', $index_files_live_extract);
+ $this->configService->setAppValue('index_files_live_update', $index_files_live_update);
+ $this->configService->setAppValue('index_files_external_index', $index_files_external_index);
+ $this->configService->setAppValue('index_files_max_size', $index_files_max_size);
$this->configService->setAppValue('display_result', $display_result);
- if ($needed_index == 1)
- $this->configService->needIndex(true, true);
+ if ($index_files_needed == 1)
+ $this->configService->needIndexFiles(true, true);
return $this->updateSubOptions(false);
}
diff --git a/lib/Cron/BackgroundIndex.php b/lib/Cron/BackgroundIndex.php
index 675db76..6aef6f6 100644
--- a/lib/Cron/BackgroundIndex.php
+++ b/lib/Cron/BackgroundIndex.php
@@ -56,12 +56,12 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
$this->rootFolder = $c->query('RootFolder');
// $this->setDebug(true);
- if (! $this->configService->neededIndex()) {
+ if (! $this->configService->neededIndexFiles()) {
$this->miscService->debug('Looks like there is no need to index');
return;
}
- $solr_locked = $this->configService->getAppValue('solr_lock');
+ $solr_locked = $this->configService->getAppValue('index_locked');
if ($solr_locked > (time() - (3600 * 24))) {
$this->miscService->log('The background index detected that your solr is locked by a running script. If it is not the case, you should start indexing manually using ./occ nextant:index --force');
return;
@@ -69,12 +69,12 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
$this->miscService->debug('Cron - Init');
- $this->configService->setAppValue('solr_lock', time());
+ $this->configService->setAppValue('index_locked', time());
if ($this->scanUsers()) {
- $this->configService->needIndex(false);
- $this->configService->setAppValue('last_index', time());
+ $this->configService->needIndexFiles(false);
+ $this->configService->setAppValue('index_files_last', time());
}
- $this->configService->setAppValue('solr_lock', '0');
+ $this->configService->setAppValue('index_locked', '0');
$this->miscService->debug('Cron - End');
}
diff --git a/lib/Events/FilesEvents.php b/lib/Events/FilesEvents.php
index dd5b962..a92481e 100644
--- a/lib/Events/FilesEvents.php
+++ b/lib/Events/FilesEvents.php
@@ -60,11 +60,11 @@ class FilesEvents
*/
public function onFileCreate($path)
{
- if ($this->configService->getAppValue('live_extract') == '1') {
+ if ($this->configService->getAppValue('index_files_live_extract') == '1') {
if ($this->fileService->addFileFromPath($path, true))
$this->fileService->updateFiles(FileService::getId($path));
} else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -74,11 +74,11 @@ class FilesEvents
*/
public function onFileUpdate($path)
{
- if ($this->configService->getAppValue('live_extract') == '1') {
+ if ($this->configService->getAppValue('index_files_live_extract') == '1') {
if ($this->fileService->addFileFromPath($path, true))
$this->fileService->updateFiles(FileService::getId($path));
} else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -88,10 +88,10 @@ class FilesEvents
*/
public function onFileRename($target)
{
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->updateFiles(FileService::getId($target));
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -102,17 +102,17 @@ class FilesEvents
public function onFileTrash($path)
{
if (\OCP\App::isEnabled('files_trashbin')) {
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->updateFiles(FileService::getId($path), array(
'deleted' => true
));
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
} else {
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->removeFiles($path);
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
}
@@ -124,11 +124,11 @@ class FilesEvents
public function onFileDelete($path)
{
// fast way to bypass files_trashbin/
- if ($this->configService->getAppValue('live_extract') == '1') {
+ if ($this->configService->getAppValue('index_files_live_extract') == '1') {
$this->fileService->setView(new \OC\Files\View('/' . $this->userId));
$this->fileService->removeFiles($path);
} else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -138,12 +138,12 @@ class FilesEvents
*/
public function onFileRestore($path)
{
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->updateFiles(FileService::getId($path), array(
'deleted' => false
));
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -153,10 +153,10 @@ class FilesEvents
*/
public function onFileShare($fileId)
{
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->updateFiles($fileId);
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
/**
@@ -166,10 +166,10 @@ class FilesEvents
*/
public function onFileUnshare($fileId)
{
- if ($this->configService->getAppValue('live_docupdate') == '1')
+ if ($this->configService->getAppValue('index_files_live_update') == '1')
$this->fileService->updateFiles($fileId);
else
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
}
}
diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php
index 7897be1..ca05aa1 100644
--- a/lib/Service/ConfigService.php
+++ b/lib/Service/ConfigService.php
@@ -35,24 +35,34 @@ class ConfigService
const SEARCH_DISPLAY_FILES = 2;
- const ACTION_LIVE_EXTRACT = 'live_extract';
+ const ACTION_LIVE_EXTRACT = 'index_files_live_extract';
- const ACTION_LIVE_DOCUPDATE = 'live_docupdate';
+ const ACTION_LIVE_DOCUPDATE = 'index_files_live_extract';
private $defaults = [
'configured' => '0',
- 'needed_index' => '2',
+ // 'needed_index' => '2',
'solr_url' => 'http://127.0.0.1:8983/solr/',
'solr_core' => 'nextant',
- 'live_extract' => '1',
- 'live_docupdate' => '0',
- 'last_index' => 0,
+ // 'live_extract' => '1',
+ // 'live_docupdate' => '0',
+ // 'last_index' => 0,
'display_result' => 1,
- 'max_size' => 40,
- 'external_index' => '0',
- 'solr_lock' => 0,
+ // 'max_size' => 40,
+ // 'external_index' => '0',
+ // 'solr_lock' => 0,
+
+ 'index_locked' => 0,
+
+ 'index_files' => 1,
+ 'index_files_needed' => 2,
+ 'index_files_last' => 0,
+ 'index_files_live_extract' => 1,
+ 'index_files_live_update' => 0,
+ 'index_files_max_size' => 40,
+
'index_bookmarks' => 0,
- 'index_bookmarks_needed' => 0,
+ 'index_bookmarks_needed' => 2,
'index_bookmarks_last' => 0
];
@@ -76,23 +86,34 @@ class ConfigService
}
}
- public function needIndex($need, $force = false)
+ public function copyConfigFrom050()
+ {
+ $this->setAppValue('index_locked', $this->getAppValue('solr_lock'));
+ $this->setAppValue('index_files_needed', $this->getAppValue('needed_index'));
+ $this->setAppValue('index_files_last', $this->getAppValue('last_index'));
+ $this->setAppValue('index_files_live_extract', $this->getAppValue('live_extract'));
+ $this->setAppValue('index_files_live_update', $this->getAppValue('live_docupdate'));
+ $this->setAppValue('index_files_max_size', $this->getAppValue('max_size'));
+ $this->setAppValue('index_files_external_index', $this->getAppValue('external_index'));
+ }
+
+ public function needIndexFiles($need, $force = false)
{
if (! $need)
- $this->setAppValue('needed_index', '0');
+ $this->setAppValue('index_files_needed', '0');
else
- if ($force || $this->getAppValue('needed_index') == '0')
- $this->setAppValue('needed_index', '1');
+ if ($force || $this->getAppValue('index_files_needed') == '0')
+ $this->setAppValue('index_files_needed', '1');
}
- public function neededIndex()
+ public function neededIndexFiles()
{
- return ($this->getAppValue('needed_index') == '1');
+ return ($this->getAppValue('index_files_needed') == '1');
}
- public function stopIndex()
+ public function stopIndexFiles()
{
- $this->setAppValue('needed_index', '2');
+ $this->setAppValue('index_files_needed', '2');
}
public function needIndexBookmarks($need)
diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php
index d15387a..8992ece 100644
--- a/lib/Service/FileService.php
+++ b/lib/Service/FileService.php
@@ -86,12 +86,12 @@ class FileService
return false;
$storage = $fileInfo->getStorage();
- if (! $storage->isLocal() && $this->configService->getAppValue('external_index') != 1)
+ if (! $storage->isLocal() && $this->configService->getAppValue('index_files_external_index') != 1)
return false;
$size = round($fileInfo->getSize() / 1024 / 1024, 1);
- if ($size > $this->configService->getAppValue('max_size')) {
- $this->miscService->debug('File is too big (' . $size . ' > ' . $this->configService->getAppValue('max_size') . ')');
+ if ($size > $this->configService->getAppValue('index_files_max_size')) {
+ $this->miscService->debug('File is too big (' . $size . ' > ' . $this->configService->getAppValue('index_files_max_size') . ')');
return false;
}
@@ -127,7 +127,7 @@ class FileService
}
if (! $result)
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
return $result;
}
@@ -186,7 +186,7 @@ class FileService
$count = $this->solrTools->updateDocuments('files', $pack, $error);
if ($count === false)
- $this->configService->needIndex(true);
+ $this->configService->needIndexFiles(true);
return $count;
}
diff --git a/lib/Service/SolrAdminService.php b/lib/Service/SolrAdminService.php
index 2911ba9..9417c4a 100644
--- a/lib/Service/SolrAdminService.php
+++ b/lib/Service/SolrAdminService.php
@@ -215,7 +215,7 @@ class SolrAdminService
}
if ($changed)
- $this->configService->setAppValue('needed_index', '1');
+ $this->configService->setAppValue('index_files_needed', '1');
$this->configService->setAppValue('configured', '1');
return true;
diff --git a/templates/settings.admin.php b/templates/settings.admin.php
index 3f127ad..a95a1a5 100644
--- a/templates/settings.admin.php
+++ b/templates/settings.admin.php
@@ -77,9 +77,9 @@ style('nextant', 'admin');
<td class="nextant_admin_left">
<?php p($l->t('Live Extract :')); ?>
</td>
- <td><input type="checkbox" name="solr_live_extract"
- id="solr_live_extract" value="1" style="margin: 10px;"> (<a
- id="nextant_help_link"
+ <td><input type="checkbox" name="solr_index_files_live_extract"
+ id="solr_index_files_live_extract" value="1"
+ style="margin: 10px;"> (<a id="nextant_help_link"
href="https://github.com/daita/nextant/wiki/Extracting,-Live-Update"
target="_blank">help</a>)</td>
</tr>
@@ -87,22 +87,23 @@ style('nextant', 'admin');
<tr style="height: 30px;">
<td class="nextant_admin_left">
<?php p($l->t('Live Document Update :')) ?></td>
- <td><input type="checkbox" name="solr_live_docupdate"
- id="solr_live_docupdate" value="1" style="margin: 10px;"></td>
+ <td><input type="checkbox" name="solr_index_files_live_update"
+ id="solr_index_files_live_update" value="1" style="margin: 10px;"></td>
</tr>
<tr style="height: 30px;">
<td class="nextant_admin_left">
<?php p($l->t('Maximum File Size (Mb) :')) ?></td>
- <td><input type="text" id="solr_max_size" style="width: 100px;"></td>
+ <td><input type="text" id="solr_index_files_max_size"
+ style="width: 100px;"></td>
</tr>
<!--
<tr style="height: 30px;">
<td class="nextant_admin_left">
<?php p($l->t('Index External Storage :')) ?></td>
- <td><input type="checkbox" name="solr_external_index"
- id="solr_external_index" value="1" style="margin: 10px;"></td>
+ <td><input type="checkbox" name="solr_index_files_external_index"
+ id="solr_index_files_external_index" value="1" style="margin: 10px;"></td>
</tr>
-->
@@ -118,7 +119,7 @@ style('nextant', 'admin');
<tr style="height: 30px;">
<td class="nextant_admin_left">
<?php p($l->t('Last index :')) ?></td>
- <td><div id="solr_last_index"></div></td>
+ <td><div id="solr_index_files_last"></div></td>
</tr>
<tr style="height: 30px;">