From fc969d40325985283c13b5556e40171e8302e1e2 Mon Sep 17 00:00:00 2001 From: yixinglu <2520865+yixinglu@users.noreply.github.com> Date: Mon, 13 Sep 2021 20:00:55 +0800 Subject: [PATCH] Fix the importing of files with wildcard in the path --- pkg/config/config.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index e4fdaa9a..8263d81f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -373,11 +373,31 @@ func (f *File) expandFiles(dir string) (err error, files []*File) { return err, files } - for _, name := range fileNames { - eachConf := f - eachConf.Path = &name + if len(fileNames) == 1 { + files = append(files, f) + return err, files + } + + for i := range fileNames { + var failedDataPath *string = nil + if f.FailDataPath != nil { + base := filepath.Base(fileNames[i]) + tmp := filepath.Join(*f.FailDataPath, base) + failedDataPath = &tmp + logger.Infof("Failed data path: %v", *failedDataPath) + } + eachConf := &File{ + Path: &fileNames[i], + FailDataPath: failedDataPath, + BatchSize: f.BatchSize, + Limit: f.Limit, + InOrder: f.InOrder, + Type: f.Type, + CSV: f.CSV, + Schema: f.Schema, + } files = append(files, eachConf) - logger.Infof("find file: %v", *f.Path) + logger.Infof("find file: %v", *eachConf.Path) } }