cmd: add directory error checking

This commit is contained in:
c9s 2022-05-09 19:40:49 +08:00
parent bff73a3a80
commit 6965baa8dd
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -344,10 +344,14 @@ var BacktestCmd = &cobra.Command{
dumpDir = filepath.Join(dumpDir, "klines") dumpDir = filepath.Join(dumpDir, "klines")
if _, err := os.Stat(dumpDir); os.IsNotExist(err) { if _, err := os.Stat(dumpDir); err != nil {
if os.IsNotExist(err) {
if err2 := os.MkdirAll(dumpDir, 0755); err2 != nil { if err2 := os.MkdirAll(dumpDir, 0755); err2 != nil {
return err2 return err2
} }
} else {
return err
}
} }
dumper := backtest.NewKLineDumper(dumpDir) dumper := backtest.NewKLineDumper(dumpDir)