Просмотр исходного кода

Merge pull request #1628 from visuddhinanda/laravel

创建导出文件目录
visuddhinanda 2 лет назад
Родитель
Сommit
5b6d609e02
2 измененных файлов с 14 добавлено и 3 удалено
  1. 2 1
      app/Console/Commands/ExportCreateDb.php
  2. 12 2
      app/Console/Commands/ExportOffline.php

+ 2 - 1
app/Console/Commands/ExportCreateDb.php

@@ -39,7 +39,8 @@ class ExportCreateDb extends Command
     public function handle()
     {
         $sqlPath = database_path('export/sentence.sql');
-        $exportFile = storage_path('app/public/export/offline/sentence-'.date("Y-m-d").'.db3');
+        $exportDir = storage_path('app/public/export/offline');
+        $exportFile = $exportDir.'/sentence-'.date("Y-m-d").'.db3';
         $file = fopen($exportFile,'w');
         fclose($file);
         $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));

+ 12 - 2
app/Console/Commands/ExportOffline.php

@@ -39,16 +39,26 @@ class ExportOffline extends Command
      */
     public function handle()
     {
-        $exportStop = storage_path('app/public/export/offline/.stop');
+        $exportDir = storage_path('app/public/export/offline');
+        if(!is_dir($exportDir)){
+            $res = mkdir($exportDir,0700,true);
+            if(!$res){
+                Log::error('mkdir fail path='.$exportDir);
+                return 1;
+            }
+        }
+        $exportStop = $exportDir.'/.stop';
         $file = fopen($exportStop,'w');
         fclose($file);
+             
         //建表
         $this->info('create db');
         $this->call('export:create.db');
+
         //term
         $this->info('term');
         $this->call('export:term');
-
+        
         //导出channel
         $this->info('channel');
         $this->call('export:channel');