From ed220996a7355b9a499e392ae269b6ab4d01c697 Mon Sep 17 00:00:00 2001 From: YGXB_net Date: Fri, 17 Oct 2025 22:34:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B3=84=E6=BC=8F=E5=92=8C=E7=A9=BA=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.go | 1 + main.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 6a6e376..701416b 100644 --- a/api/api.go +++ b/api/api.go @@ -19,6 +19,7 @@ func UploadDataToServer(httpClient *http.Client, data string) error { } if resp != nil { _, _ = io.Copy(io.Discard, resp.Body) + resp.Body.Close() } return err } diff --git a/main.go b/main.go index 101dd34..43b4dae 100644 --- a/main.go +++ b/main.go @@ -113,7 +113,7 @@ func main() { AddLog(s) isRun = true - go StartLooking(ctx, selectedDirLabel.Text) + go StartLooking(ctx, config.APPConfig.LookingPath) }) stopBtn := widget.NewButton("停止运行", func() { @@ -213,7 +213,7 @@ func main() { AddLog(s) isRun = true - go StartLooking(ctx, selectedDirLabel.Text) + go StartLooking(ctx, config.APPConfig.LookingPath) }() myWindow.SetContent(splitContainer) @@ -247,6 +247,7 @@ type Task struct { } func StartLooking(ctx context.Context, lookingPath string) { + AddLog("正在运行上传程序") t := time.NewTicker(time.Minute) defer t.Stop() @@ -269,6 +270,7 @@ func StartLooking(ctx context.Context, lookingPath string) { //统计文件行数 fileLines := make(map[string]int) AddLog(fmt.Sprintf("正在统计 %v 个文件行数", len(files))) + isAllEmpty := true for _, filePath := range files { select { case <-ctx.Done(): @@ -290,9 +292,16 @@ func StartLooking(ctx context.Context, lookingPath string) { continue } fileLines[filepath.Base(filePath)] = lineCount + if lineCount != 0 { + isAllEmpty = false + } AddLog(fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount)) } } + if isAllEmpty { + AddLog("所有文件都为空,不进行上传") + return + } //添加任务 var tasks []Task