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.js25
-rw-r--r--lib/Cron/BackgroundIndex.php2
-rw-r--r--lib/Db/LiveQueueMapper.php4
-rw-r--r--lib/Events/FilesEvents.php16
-rw-r--r--lib/Service/ConfigService.php1
-rw-r--r--lib/Service/QueueService.php111
-rw-r--r--templates/settings.admin.php10
7 files changed, 87 insertions, 82 deletions
diff --git a/js/settings.admin.js b/js/settings.admin.js
index a525cad..736becc 100644
--- a/js/settings.admin.js
+++ b/js/settings.admin.js
@@ -175,17 +175,13 @@ $(document)
force_index = 1;
var data = {
- resource_level : $('#solr_resource_level').val(),
- index_live : ($('#solr_index_live')
- .is(':checked')) ? 1 : 0,
+ resource_level : $('#solr_resource_level')
+ .val(),
+ index_live : $('#solr_index_live').val(),
index_delay : $('#solr_index_delay').val(),
force_index : force_index
}
- if (switched == 'index_live')
- data.index_live = (data.index_live == 1) ? 0
- : 1;
-
$.post(OC.filePath('nextant', 'ajax/settings',
'option_status.php'), data,
nextantSettings.updatesuboptions);
@@ -224,8 +220,12 @@ $(document)
$('#nextant_suboptions').fadeTo(delay, 1);
$('#solr_index_live_queuekey').prop('disabled',
true);
- $('#solr_index_live_queuekey').fadeTo(delay,
- 0.85);
+ if (response.index_live == 1)
+ $('#solr_index_live_queuekey').fadeTo(
+ delay, 0.85);
+ else
+ $('#solr_index_live_queuekey').fadeTo(
+ delay, 0);
} else {
$('#nextant_suboptions :input').attr(
"disabled", true);
@@ -296,8 +296,7 @@ $(document)
$('#solr_resource_level').val(
response.resource_level);
- $('#solr_index_live').prop('checked',
- (response.index_live == 1));
+ $('#solr_index_live').val(response.index_live);
$('#solr_index_live_queuekey').val(
response.index_live_queuekey);
$('#solr_index_delay').val(response.index_delay);
@@ -689,8 +688,8 @@ $(document)
nextantSettings.savesuboptions_status();
});
- $('#solr_index_live').mousedown(function() {
- nextantSettings.savesuboptions_status('index_live');
+ $('#solr_index_live').on('change', function() {
+ nextantSettings.savesuboptions_status();
});
$('#solr_index_delay').on('input', function(e) {
diff --git a/lib/Cron/BackgroundIndex.php b/lib/Cron/BackgroundIndex.php
index c6ceed0..b64f70d 100644
--- a/lib/Cron/BackgroundIndex.php
+++ b/lib/Cron/BackgroundIndex.php
@@ -89,7 +89,7 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob
private function liveIndex()
{
- if ($this->configService->getAppValue('index_live') !== '1')
+ if ($this->configService->getAppValue('index_live') === '0')
return;
while (($item = $this->queueService->readQueue()) !== false) {
diff --git a/lib/Db/LiveQueueMapper.php b/lib/Db/LiveQueueMapper.php
index 5c35b46..0545334 100644
--- a/lib/Db/LiveQueueMapper.php
+++ b/lib/Db/LiveQueueMapper.php
@@ -40,7 +40,7 @@ class LiveQueueMapper extends Mapper
{
parent::__construct($db, self::TABLENAME, 'OCA\Nextant\Db\LiveQueue');
}
-
+
public function find($id)
{
$sql = 'SELECT * FROM *PREFIX*' . self::TABLENAME . ' WHERE id = ?';
@@ -68,7 +68,7 @@ class LiveQueueMapper extends Mapper
public function clear()
{
$sql = 'TRUNCATE *PREFIX*' . self::TABLENAME;
- return $this->execute();
+ return $this->execute($sql);
}
}
diff --git a/lib/Events/FilesEvents.php b/lib/Events/FilesEvents.php
index c5992c7..125635f 100644
--- a/lib/Events/FilesEvents.php
+++ b/lib/Events/FilesEvents.php
@@ -78,7 +78,7 @@ class FilesEvents
*/
public function onFileCreate($path)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($path, Filesystem::getView());
if ($file === false)
return;
@@ -99,7 +99,7 @@ class FilesEvents
*/
public function onFileUpdate($path)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($path, Filesystem::getView());
if ($file->getId() > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_UPDATE, array(
@@ -117,7 +117,7 @@ class FilesEvents
*/
public function onFileRename($target)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($target, Filesystem::getView());
if ($file->getId() > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_RENAME, array(
@@ -135,7 +135,7 @@ class FilesEvents
*/
public function onFileTrash($path)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($path, Filesystem::getView());
if ($file->getId() > 0) {
if (\OCP\App::isEnabled('files_trashbin'))
@@ -162,7 +162,7 @@ class FilesEvents
*/
public function onFileDelete($path)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($path, new \OC\Files\View('/' . $this->userId));
if ($file->getId() > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_DELETE, array(
@@ -181,7 +181,7 @@ class FilesEvents
*/
public function onFileRestore($path)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
$file = FileService::getFileInfoFromPath($path, Filesystem::getView());
if ($file->getId() > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_RESTORE, array(
@@ -199,7 +199,7 @@ class FilesEvents
*/
public function onFileShare($fileId)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
if ($fileId > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_SHARE, array(
'userid' => $this->userId,
@@ -216,7 +216,7 @@ class FilesEvents
*/
public function onFileUnshare($fileId)
{
- if ($this->configService->getAppValue('index_live') === '1') {
+ if ($this->configService->getAppValue('index_live') !== '0') {
if ($fileId > 0)
$this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_UNSHARE, array(
'userid' => $this->userId,
diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php
index 4c22626..0e30774 100644
--- a/lib/Service/ConfigService.php
+++ b/lib/Service/ConfigService.php
@@ -54,7 +54,6 @@ class ConfigService
'resource_level' => '4',
'index_live' => '1',
- 'index_live_sql' => '1',
'index_live_queuekey' => '19375',
'index_delay' => '2',
'index_locked' => '0',
diff --git a/lib/Service/QueueService.php b/lib/Service/QueueService.php
index 2393019..91dd974 100644
--- a/lib/Service/QueueService.php
+++ b/lib/Service/QueueService.php
@@ -64,74 +64,79 @@ class QueueService
public function liveIndex($item)
{
- if ($this->configService->getAppValue('index_live') !== '1')
- return;
-
- if ($this->configService->getAppValue('index_live_sql') === '1')
- $this->liveQueueMapper->insert(new LiveQueue($item));
-
- else {
- $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey'));
+ switch ($this->configService->getAppValue('index_live')) {
+ case '0':
+ return;
+
+ case '1':
+ $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey'));
+ if (! msg_send($queue, 1, ItemQueue::toJson($item)))
+ $this->miscService->log('can\'t msg_send()');
+ break;
- if (! msg_send($queue, 1, ItemQueue::toJson($item)))
- $this->miscService->log('can\'t msg_send()');
+ case '2':
+ $this->liveQueueMapper->insert(new LiveQueue($item));
+ break;
}
}
public function emptyQueue()
{
- if ($this->configService->getAppValue('index_live') !== '1')
- return;
-
- if ($this->configService->getAppValue('index_live_sql') === '1')
- $this->liveQueueMapper->clear();
- else
- msg_remove_queue(msg_get_queue($this->configService->getAppValue('index_live_queuekey')));
+ switch ($this->configService->getAppValue('index_live')) {
+ case '0':
+ return;
+
+ case '1':
+ msg_remove_queue(msg_get_queue($this->configService->getAppValue('index_live_queuekey')));
+ break;
+
+ case '2':
+ $this->liveQueueMapper->clear();
+ break;
+ }
}
public function readQueue($standby = false)
{
- if ($this->configService->getAppValue('index_live') !== '1')
- return;
-
- $msg = NULL;
- if ($this->configService->getAppValue('index_live_sql') === '1') {
+ switch ($this->configService->getAppValue('index_live')) {
+ case '0':
+ return;
- while (true) {
+ case '1':
+ $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey'));
- if ($this->parent != null)
- $this->parent->interrupted();
+ $msg_type = null;
+ $msg = null;
+ $max_msg_size = 512;
- $queue = $this->liveQueueMapper->next();
- if ($queue)
- break;
- if (! $standby && ! $queue)
- break;
- sleep(15);
- }
-
- if ($queue)
- $msg = $queue->getItem();
-
- } else {
- $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey'));
-
- $msg_type = NULL;
- $max_msg_size = 512;
-
- $infos = msg_stat_queue($queue);
- if (! $standby && $infos['msg_qnum'] == 0)
- return false;
+ $infos = msg_stat_queue($queue);
+ if (! $standby && $infos['msg_qnum'] == 0)
+ return false;
+
+ if (! msg_receive($queue, 1, $msg_type, $max_msg_size, $msg, true, 0, $error))
+ return false;
+
+ return ItemQueue::fromJson($msg);
- if (! msg_receive($queue, 1, $msg_type, $max_msg_size, $msg, true, 0, $error)) {
- return false;
- }
+ case '2':
+ $msg = null;
+ while (true) {
+ if ($this->parent != null)
+ $this->parent->interrupted();
+
+ $queue = $this->liveQueueMapper->next();
+ if ($queue)
+ break;
+ if (! $standby && ! $queue)
+ break;
+ sleep(15);
+ }
+
+ if ($queue)
+ $msg = $queue->getItem();
+
+ return ItemQueue::fromJson($msg);
}
-
- if ($msg == NULL)
- return;
-
- return ItemQueue::fromJson($msg);
}
public function executeItem($item)
diff --git a/templates/settings.admin.php b/templates/settings.admin.php
index cb0e6ac..4aa9f8a 100644
--- a/templates/settings.admin.php
+++ b/templates/settings.admin.php
@@ -209,7 +209,7 @@ style('nextant', 'admin');
<?php p($l->t('Resource Level :')); ?>
</td>
<td colspan="2"><select name="solr_resource_level"
- id="solr_resource_level">
+ id="solr_resource_level" style="width: 200px">
<!-- <option value="5">Higher Level</option> -->
<option value="4">High performance</option>
<!-- <option value="3">Mid level</option> -->
@@ -222,9 +222,11 @@ style('nextant', 'admin');
<td class="nextant_admin_left">
<?php p($l->t('Live Index :')); ?>
</td>
- <td colspan="2"><input type="checkbox" name="solr_index_live"
- id="solr_index_live" value="1" style="margin: 10px;"> <input
- type="text" id="solr_index_live_queuekey"
+ <td colspan="2"><select id="solr_index_live" style="width: 200px">
+ <option value="0">Disabled</option>
+ <option value="1">Using Semaphore</option>
+ <option value="2">Using Database</option>
+ </select> <input type="text" id="solr_index_live_queuekey"
style="width: 100px; font-size: 12px;" /></td>
</tr>