diff options
author | daita <maxence@pontapreta.net> | 2016-10-08 01:29:06 +0300 |
---|---|---|
committer | daita <maxence@pontapreta.net> | 2016-10-08 01:29:06 +0300 |
commit | fe88172a62fdb1ee110226f73392a867ed580347 (patch) | |
tree | 9d6327a2f80aa8b9bb64971fe8972dcb5fe36233 | |
parent | 36c19dbf6e95dce224f063d8612fcb210c42773b (diff) |
external_index
-rw-r--r-- | js/settings.admin.js | 11 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 6 | ||||
-rw-r--r-- | lib/Service/ConfigService.php | 3 | ||||
-rw-r--r-- | lib/Service/FileService.php | 22 | ||||
-rw-r--r-- | templates/settings.admin.php | 9 |
5 files changed, 45 insertions, 6 deletions
diff --git a/js/settings.admin.js b/js/settings.admin.js index d1d93b9..64f0561 100644 --- a/js/settings.admin.js +++ b/js/settings.admin.js @@ -47,6 +47,8 @@ $(document) live_docupdate : ($('#solr_live_docupdate') .is(':checked')) ? 1 : 0, max_size : $('#solr_max_size').val(), + external_index : ($('#solr_external_index') + .is(':checked')) ? 1 : 0, display_result : $('#solr_display_result') .val(), needed_index : needed_index @@ -59,6 +61,10 @@ $(document) data.live_docupdate = (data.live_docupdate == 1) ? 0 : 1; + if (switched == 'external_index') + data.external_index = (data.external_index == 1) ? 0 + : 1; + $.post(OC.filePath('nextant', 'ajax/settings', 'option.php'), data, nextantSettings.updatesuboptions); @@ -98,6 +104,8 @@ $(document) (response.live_extract == 1)); $('#solr_live_docupdate').prop('checked', (response.live_docupdate == 1)); + $('#solr_external_index').prop('checked', + (response.external_index == 1)); if (response.last_index > 0) $('#solr_last_index').text( @@ -328,6 +336,9 @@ $(document) $('#solr_max_size').on('input', function(e) { nextantSettings.savesuboptions(); }); + $('#solr_external_index').mousedown(function() { + nextantSettings.savesuboptions('external_index'); + }); $('#nextant_force_index').on('click', function() { nextantSettings.savesuboptions('force_index'); }); diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index edd08e2..afbf8bf 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -83,7 +83,7 @@ class SettingsController extends Controller 'instant' => $instant, 'configured' => $this->configService->getAppValue('configured'), 'ping' => $this->solrAdmin->ping($error), - 'nextant_version' => $this->configService->getAppValue('installed_version') . ' (beta)', + 'nextant_version' => $this->configService->getAppValue('installed_version') . ' (beta)', 'current_docs' => $this->solrTools->count($error), 'last_index' => $this->configService->getAppValue('last_index'), 'last_index_format' => date('r', $this->configService->getAppValue('last_index')), @@ -92,16 +92,18 @@ class SettingsController extends Controller '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'), 'solr_lock' => $this->configService->getAppValue('solr_lock') ); return $response; } - public function setOptions($live_extract, $live_docupdate, $max_size, $display_result, $needed_index) + public function setOptions($live_extract, $live_docupdate, $max_size, $external_index, $display_result, $needed_index) { $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('display_result', $display_result); if ($needed_index == 1) diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 4095005..6b867c1 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -47,8 +47,9 @@ class ConfigService 'live_extract' => '1', 'live_docupdate' => '0', 'last_index' => 0, - 'display_result' => 2, + 'display_result' => 1, 'max_size' => 40, + 'external_index' => '0', 'solr_lock' => 0 ]; diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 3d47ad8..afa61b3 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -85,6 +85,10 @@ class FileService if ($fileInfo == null) return false; + $storage = $fileInfo->getStorage(); + if (! $storage->isLocal() && $this->configService->getAppValue('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') . ')'); @@ -101,12 +105,24 @@ class FileService $this->miscService->debug('Extracting file ' . $path); + $storage = $fileInfo->getStorage(); $status = 1; - - if ($fileInfo->getStorage()->isLocal()) + if ($storage->isLocal()) $result = $this->solrService->extractFile($this->view->getLocalFile($path), $fileInfo->getId(), $path, $fileInfo->getMTime()); else { - // not local + + // create a temp file containing the remote file to send to solr + // returns: + // [OCP\Files\StorageNotAvailableException] + // Dropbox API rate limit exceeded + + // [Dropbox_Exception_Forbidden] + // Forbidden. Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user. + + $tmp_file = tempnam(sys_get_temp_dir(), 'nextant_' . $storage->getId() . '_'); + $content = $storage->file_get_contents($path); + file_put_contents($tmp_file, $content); + return false; } diff --git a/templates/settings.admin.php b/templates/settings.admin.php index 4e5b416..f219b9a 100644 --- a/templates/settings.admin.php +++ b/templates/settings.admin.php @@ -97,6 +97,15 @@ style('nextant', 'admin'); <td><input type="text" id="solr_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> + </tr> + --> + <tr style="height: 30px;"> <td class="nextant_admin_left"> <?php p($l->t('Display result :')) ?></td> |