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

删除旧的zip文件之前先检查是否存在

visuddhinanda 2 лет назад
Родитель
Сommit
a674d8289a
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      app/Console/Commands/ExportZip.php

+ 5 - 4
app/Console/Commands/ExportZip.php

@@ -68,11 +68,12 @@ class ExportZip extends Command
             $this->error('export offline: no db file {filename}'.$exportFullFileName);
             return 1;
         }
-        $zipFullFileName = storage_path($exportPath.'/'.$zipFile);
-
-        unlink($zipFullFileName);
 
-        Log::debug('export offline: delete old file:'.$zipFullFileName);
+        $zipFullFileName = storage_path($exportPath.'/'.$zipFile);
+        if(file_exists($zipFullFileName)){
+            Log::debug('export offline: delete old zip file:'.$zipFullFileName);
+            unlink($zipFullFileName);
+        }
 
         shell_exec("cd ".storage_path($exportPath));
         if($this->argument('format')==='7z'){