Jelajahi Sumber

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

visuddhinanda 2 tahun lalu
induk
melakukan
a674d8289a
1 mengubah file dengan 5 tambahan dan 4 penghapusan
  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'){