diff options
author | daita <maxence@pontapreta.net> | 2016-11-09 01:10:01 +0300 |
---|---|---|
committer | daita <maxence@pontapreta.net> | 2016-11-09 01:10:01 +0300 |
commit | 89194d16dbaf7b4f4549b78d76c43437d1743510 (patch) | |
tree | c521f94f44c65680d38fc1b8009f0f5ff91cc190 | |
parent | d8fcfeff0b1c66de53ce0fa05a73e8566f3f0dc2 (diff) |
queueID is now unique
-rw-r--r-- | js/settings.admin.js | 34 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 2 | ||||
-rw-r--r-- | lib/Command/Live.php | 2 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 15 | ||||
-rw-r--r-- | lib/Events/FilesEvents.php | 16 | ||||
-rw-r--r-- | lib/Service/ConfigService.php | 26 | ||||
-rw-r--r-- | lib/Service/QueueService.php | 14 | ||||
-rw-r--r-- | templates/settings.admin.php | 21 |
8 files changed, 58 insertions, 72 deletions
diff --git a/js/settings.admin.js b/js/settings.admin.js index 888e044..ebe171b 100644 --- a/js/settings.admin.js +++ b/js/settings.admin.js @@ -60,8 +60,6 @@ $(document) var data = { index_files : ($('#solr_index_files') .is(':checked')) ? 1 : 0, - index_files_live : ($('#solr_index_files_live') - .is(':checked')) ? 1 : 0, index_files_max_size : $( '#solr_index_files_max_size').val(), index_files_tree : ($('#solr_index_files_tree') @@ -77,9 +75,6 @@ $(document) if (switched == 'index_files') data.index_files = (data.index_files == 1) ? 0 : 1; - if (switched == 'index_files_live') - data.index_files_live = (data.index_files_live == 1) ? 0 - : 1; if (switched == 'index_files_tree') data.index_files_tree = (data.index_files_tree == 1) ? 0 @@ -168,6 +163,8 @@ $(document) force_index = 1; var data = { + index_live : ($('#solr_index_live') + .is(':checked')) ? 1 : 0, index_delay : $('#solr_index_delay').val(), display_result : $('#solr_display_result') .val(), @@ -180,6 +177,10 @@ $(document) data.replace_core_search = (data.replace_core_search == 1) ? 0 : 1; + 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); @@ -208,10 +209,12 @@ $(document) $('#solr_timeout').val(response.solr_timeout); if (response.configured > 0) { - $('#nextant_suboptions :input').attr( - "disabled", false); + $('#nextant_suboptions :input').prop( + 'disabled', false); $('#nextant_help_link').unbind('click'); $('#nextant_suboptions').fadeTo(delay, 1); + $('#solr_index_live_queuekey').prop('disabled', true); + $('#solr_index_live_queuekey').fadeTo(delay, 0.85); } else { $('#nextant_suboptions :input').attr( "disabled", true); @@ -224,8 +227,6 @@ $(document) $('#solr_index_files').prop('checked', (response.index_files == 1)); - $('#solr_index_files_live').prop('checked', - (response.index_files_live == 1)); $('#solr_index_files_tree').prop('checked', (response.index_files_tree == 1)); $('#solr_index_files_sharelink').prop('checked', @@ -278,6 +279,10 @@ $(document) else $('#solr_sub_bookmarks').hide(delay); + $('#solr_index_live').prop('checked', + (response.index_live == 1)); + $('#solr_index_live_queuekey').val( + response.index_live_queuekey); $('#solr_index_delay').val(response.index_delay); $( @@ -570,12 +575,6 @@ $(document) $('#nextant-filters').hide(); - $('#solr_index_files_live') - .mousedown( - function() { - nextantSettings - .savesuboptions_files('index_files_live'); - }); $('#solr_index_files_max_size').on('input', function(e) { nextantSettings.savesuboptions_files(); }); @@ -656,6 +655,11 @@ $(document) $('#nextant_force_first_index').on('click', function() { nextantSettings.savesuboptions_status('force_index'); }); + + $('#solr_index_live').mousedown(function() { + nextantSettings.savesuboptions_status('index_live'); + }); + $('#solr_index_delay').on('input', function(e) { nextantSettings.savesuboptions_status(); }); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 6fa1f09..e1c11c5 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -78,7 +78,7 @@ class Application extends App }); $container->registerService('QueueService', function ($c) { - return new QueueService($c->query('IndexService'), $c->query('FileService'), $c->query('MiscService')); + return new QueueService($c->query('ConfigService'), $c->query('IndexService'), $c->query('FileService'), $c->query('MiscService')); }); $container->registerService('FileService', function ($c) { diff --git a/lib/Command/Live.php b/lib/Command/Live.php index e856df8..336c841 100644 --- a/lib/Command/Live.php +++ b/lib/Command/Live.php @@ -99,7 +99,7 @@ class Live extends Base return; } - if ($this->configService->getAppValue('index_files_live') !== '1') + if ($this->configService->getAppValue('index_live') !== '1') { $output->writeln('your nextant is not configured for Live Index'); return; diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 690697f..9647055 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -97,7 +97,6 @@ class SettingsController extends Controller 'index_files' => $this->configService->getAppValue('index_files'), 'index_files_needed' => $this->configService->getAppValue('index_files_needed'), 'index_files_max_size' => $this->configService->getAppValue('index_files_max_size'), - 'index_files_live' => $this->configService->getAppValue('index_files_live'), 'index_files_tree' => $this->configService->getAppValue('index_files_tree'), 'index_files_sharelink' => $this->configService->getAppValue('index_files_sharelink'), 'index_files_external' => $this->configService->getAppValue('index_files_external'), @@ -114,6 +113,8 @@ class SettingsController extends Controller 'bookmarks_app_enabled' => (\OCP\App::isEnabled('bookmarks')), 'index_bookmarks' => $this->configService->getAppValue('index_bookmarks'), 'index_bookmarks_needed' => $this->configService->getAppValue('index_bookmarks_needed'), + 'index_live' => $this->configService->getAppValue('index_live'), + 'index_live_queuekey' => $this->configService->getAppValue('index_live_queuekey'), 'index_delay' => $this->configService->getAppValue('index_delay'), 'index_locked' => $this->configService->getAppValue('index_locked'), 'index_files_last' => $this->configService->getAppValue('index_files_last'), @@ -126,10 +127,9 @@ class SettingsController extends Controller return $response; } - public function setOptionsFiles($index_files, $index_files_live, $index_files_max_size, $index_files_tree, $index_files_sharelink, $index_files_external, $index_files_encrypted, $index_files_filters) + public function setOptionsFiles($index_files, $index_files_max_size, $index_files_tree, $index_files_sharelink, $index_files_external, $index_files_encrypted, $index_files_filters) { $this->configService->setAppValue('index_files', $index_files); - $this->configService->setAppValue('index_files_live', $index_files_live); $this->configService->setAppValue('index_files_tree', $index_files_tree); $this->configService->setAppValue('index_files_sharelink', $index_files_sharelink); $this->configService->setAppValue('index_files_external', $index_files_external); @@ -160,12 +160,17 @@ class SettingsController extends Controller return $this->updateSubOptions(false, 'bookmarks'); } - public function setOptionsStatus($index_delay, $display_result, $replace_core_search, $force_index) + public function setOptionsStatus($index_live, $index_delay, $display_result, $replace_core_search, $force_index) { + if ($index_live === '1' && $this->configService->getAppValue('index_live') !== '1') + $this->configService->setAppValue('index_live_queuekey', rand(20000, 990000)); + + $this->configService->setAppValue('index_live', $index_live); + if ($index_delay > 0) $this->configService->setAppValue('index_delay', $index_delay); $this->configService->setAppValue('display_result', $display_result); - // $this->configService->setAppValue('replace_core_search', $replace_core_search); + // $this->configService->setAppValue('replace_core_search', $replace_core_search); if ($force_index === '1') { $this->configService->setAppValue('configured', '1'); diff --git a/lib/Events/FilesEvents.php b/lib/Events/FilesEvents.php index 42e1df2..6efc77f 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_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($path, Filesystem::getView()); if ($file->getId() > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_CREATE, array( @@ -96,7 +96,7 @@ class FilesEvents */ public function onFileUpdate($path) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($path, Filesystem::getView()); if ($file->getId() > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_UPDATE, array( @@ -114,7 +114,7 @@ class FilesEvents */ public function onFileRename($target) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($target, Filesystem::getView()); if ($file->getId() > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_RENAME, array( @@ -132,7 +132,7 @@ class FilesEvents */ public function onFileTrash($path) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($path, Filesystem::getView()); if ($file->getId() > 0) { if (\OCP\App::isEnabled('files_trashbin')) @@ -159,7 +159,7 @@ class FilesEvents */ public function onFileDelete($path) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($path, new \OC\Files\View('/' . $this->userId)); if ($file->getId() > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_DELETE, array( @@ -178,7 +178,7 @@ class FilesEvents */ public function onFileRestore($path) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { $file = FileService::getFileInfoFromPath($path, Filesystem::getView()); if ($file->getId() > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_RESTORE, array( @@ -196,7 +196,7 @@ class FilesEvents */ public function onFileShare($fileId) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { if ($fileId > 0) $this->queueService->liveIndex(new ItemQueue(FilesEvents::FILE_SHARE, array( 'userid' => $this->userId, @@ -213,7 +213,7 @@ class FilesEvents */ public function onFileUnshare($fileId) { - if ($this->configService->getAppValue('index_files_live') === '1') { + if ($this->configService->getAppValue('index_live') === '1') { 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 1af88a3..e7a6769 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -36,10 +36,6 @@ class ConfigService const SEARCH_DISPLAY_FILES = 2; - const ACTION_LIVE_EXTRACT = 'index_files_live'; - - const ACTION_LIVE_DOCUPDATE = 'index_files_live'; - private $defaults = [ 'configured' => '0', 'solr_url' => 'http://127.0.0.1:8983/solr/', @@ -48,6 +44,8 @@ class ConfigService 'display_result' => 1, 'replace_core_search' => 0, + 'index_live' => 1, + 'index_live_queuekey' => 19375, 'index_delay' => 2, 'index_locked' => 0, 'index_files_last' => 0, @@ -60,7 +58,6 @@ class ConfigService 'undex_files_sharelink' => 0, 'index_files_external' => 0, 'index_files_encrypted' => 0, - 'index_files_live' => 1, 'index_files_max_size' => 40, 'index_files_filters_text' => 1, 'index_files_filters_pdf' => 1, @@ -105,6 +102,7 @@ class ConfigService $this->deleteAppValue('max_size'); $this->deleteAppValue('external_index'); $this->deleteAppValue('index_files_live_extract'); + $this->deleteAppValue('index_files_live'); $this->deleteAppValue('index_files_live_update'); } @@ -218,24 +216,6 @@ class ConfigService return $this->config->deleteAppValue($this->appName, $key); } - /** - * return if config allow to perform action - * - * @param string $action - * @return boolean - */ - // public function shoudIContinue($action) - // { - // switch ($action) { - // case self::ACTION_LIVE_EXTRACT: - // return ($this->getAppValue($action) == '1'); - - // case self::ACTION_LIVE_DOCUPDATE: - // if ($this->getAppValue(self::ACTION_LIVE_EXTRACT) != '1') - // return false; - // return ($this->getAppValue($action) == '1'); - // } - // } public function getFileFilters() { if ($this->fileFilters == null) diff --git a/lib/Service/QueueService.php b/lib/Service/QueueService.php index 1b7afce..f475671 100644 --- a/lib/Service/QueueService.php +++ b/lib/Service/QueueService.php @@ -33,10 +33,10 @@ use \OCA\Nextant\Items\ItemDocument; class QueueService { - const QUEUE_ID = 19375; - private $userId; + private $configService; + private $indexService; private $fileService; @@ -45,9 +45,9 @@ class QueueService private $queue = null; - public function __construct($indexService, $fileService, $miscService) + public function __construct($configService, $indexService, $fileService, $miscService) { - // $this->configService = $configService;\ + $this->configService = $configService; $this->indexService = $indexService; $this->fileService = $fileService; $this->miscService = $miscService; @@ -55,7 +55,7 @@ class QueueService public function liveIndex($item) { - $queue = msg_get_queue(self::QUEUE_ID); + $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey')); $msg = ItemQueue::toJson($item); if (! msg_send($queue, 1, $msg)) @@ -64,12 +64,12 @@ class QueueService public function emptyQueue() { - msg_remove_queue(msg_get_queue(self::QUEUE_ID)); + msg_remove_queue(msg_get_queue($this->configService->getAppValue('index_live_queuekey'))); } public function readQueue($standby = false) { - $queue = msg_get_queue(self::QUEUE_ID); + $queue = msg_get_queue($this->configService->getAppValue('index_live_queuekey')); $msg_type = NULL; $msg = NULL; diff --git a/templates/settings.admin.php b/templates/settings.admin.php index 54661e6..565b3b6 100644 --- a/templates/settings.admin.php +++ b/templates/settings.admin.php @@ -104,18 +104,6 @@ style('nextant', 'admin'); </td> </tr> - - <tr style="height: 30px;"> - <td class="nextant_admin_left"> - <?php p($l->t('Live Index :')); ?> - </td> - <td colspan="2"><input type="checkbox" - name="solr_index_files_live" id="solr_index_files_live" - 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> - <tr style="height: 30px;"> <td class="nextant_admin_left"> <?php p($l->t('Index Files Tree :')) ?></td> @@ -204,6 +192,15 @@ style('nextant', 'admin'); </tr> <tr style="height: 30px;"> + <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" style="width: 100px; font-size: 12px;" /></td> + </tr> + + <tr style="height: 30px;"> <td class="nextant_admin_left"> <?php p($l->t('Background Index delay :')) ?></td> <td><input type="text" name="solr_index_delay" |