This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
13
main.go
13
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
|
||||
|
||||
Reference in New Issue
Block a user