From 7c7b42efd3bf55be0038eef679ec34387ff31e83 Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Tue, 27 Aug 2024 09:10:46 +0800 Subject: [PATCH] fix: export table task dir --- .../crontask/processor/exportTable/exportTable.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/crontask/processor/exportTable/exportTable.go b/src/modules/crontask/processor/exportTable/exportTable.go index 8e795710..a20972b1 100644 --- a/src/modules/crontask/processor/exportTable/exportTable.go +++ b/src/modules/crontask/processor/exportTable/exportTable.go @@ -48,6 +48,14 @@ func (s *BarProcessor) Execute(data any) (any, error) { return nil, err } + // mkdir if not exist + if _, err = os.Stat(params.FilePath); os.IsNotExist(err) { + err = os.MkdirAll(params.FilePath, os.ModePerm) + if err != nil { + log.Error("Failed to Mkdir:", err) + return nil, err + } + } //duration = params.Duration // 查询数据 @@ -71,7 +79,7 @@ func (s *BarProcessor) Execute(data any) (any, error) { params.Columns, params.TableName, params.TimeCol, params.Duration, unitNum, params.TimeCol, params.Duration, unitNum) } - log.Trace("query:", query) + //log.Trace("query:", query) //filePath := fmt.Sprintf("%s/%s_export_%s.csv", params.FilePath, params.TableName, time.Now().Format("20060102150405")) filePath := fmt.Sprintf("%s/%s_export_%s.csv", params.FilePath, params.TableName, time.Now().Format("20060102150405")) affected, err := s.exportData(query, filePath)