Skip to content

Commit

Permalink
如果存放索引的目录不存在,则创建,并且赋予 777 权限
Browse files Browse the repository at this point in the history
  • Loading branch information
vanry committed Sep 25, 2017
1 parent f9521a8 commit bfcef4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
```php

'tntsearch' => [
'storage' => storage_path(),
'storage' => storage_path(), //必须有可写权限
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
'asYouType' => false,
Expand Down
2 changes: 1 addition & 1 deletion config/scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [

'tntsearch' => [
'storage' => storage_path('index'),
'storage' => storage_path('index'), //必须有可写权限
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
'asYouType' => false,
Expand Down
7 changes: 6 additions & 1 deletion src/Engines/TNTSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ public function initIndex($model)
{
$indexName = $model->searchableAs();

if (! file_exists($this->tnt->config['storage']."/{$indexName}.index")) {
if (! file_exists($storage = $this->tnt->config['storage'])) {
mkdir($storage, 0777, true);
chmod($storage, 0777);
}

if (! file_exists($storage."/{$indexName}.index")) {
$indexer = $this->tnt->createIndex("$indexName.index");
$indexer->setDatabaseHandle($model->getConnection()->getPdo());
$indexer->setPrimaryKey($model->getKeyName());
Expand Down

0 comments on commit bfcef4e

Please sign in to comment.