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

导出前删除全部的旧文件

visuddhinanda 2 лет назад
Родитель
Сommit
1352459cf9
1 измененных файлов с 8 добавлено и 9 удалено
  1. 8 9
      app/Console/Commands/ExportOffline.php

+ 8 - 9
app/Console/Commands/ExportOffline.php

@@ -53,6 +53,13 @@ class ExportOffline extends Command
                 return 1;
             }
         }
+
+        //删除全部的旧文件
+        foreach (scandir($exportDir) as $key => $file) {
+            if(is_file($exportDir.'/'.$file)){
+                unlink($exportDir.'/'.$file);
+            }
+        }
         $exportStop = $exportDir.'/.stop';
         $file = fopen($exportStop,'w');
         fclose($file);
@@ -103,15 +110,7 @@ class ExportOffline extends Command
             'format'=>$this->argument('format'),
         ]);
 
-        //删除全部的旧文件
-        $fullPath = storage_path($exportPath);
-        foreach (scandir($exportDir) as $key => $file) {
-            if(is_file($exportDir.'/'.$file)){
-                if($file !== '.stop'){
-                    unlink($exportDir.'/'.$file);
-                }
-            }
-        }
+
         return 0;
     }
 }