This commit is contained in:
@@ -19,6 +19,7 @@ func UploadDataToServer(httpClient *http.Client, data string) error {
|
|||||||
}
|
}
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
_, _ = io.Copy(io.Discard, resp.Body)
|
_, _ = io.Copy(io.Discard, resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -113,7 +113,7 @@ func main() {
|
|||||||
AddLog(s)
|
AddLog(s)
|
||||||
|
|
||||||
isRun = true
|
isRun = true
|
||||||
go StartLooking(ctx, selectedDirLabel.Text)
|
go StartLooking(ctx, config.APPConfig.LookingPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
stopBtn := widget.NewButton("停止运行", func() {
|
stopBtn := widget.NewButton("停止运行", func() {
|
||||||
@@ -213,7 +213,7 @@ func main() {
|
|||||||
AddLog(s)
|
AddLog(s)
|
||||||
|
|
||||||
isRun = true
|
isRun = true
|
||||||
go StartLooking(ctx, selectedDirLabel.Text)
|
go StartLooking(ctx, config.APPConfig.LookingPath)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
myWindow.SetContent(splitContainer)
|
myWindow.SetContent(splitContainer)
|
||||||
@@ -247,6 +247,7 @@ type Task struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StartLooking(ctx context.Context, lookingPath string) {
|
func StartLooking(ctx context.Context, lookingPath string) {
|
||||||
|
AddLog("正在运行上传程序")
|
||||||
t := time.NewTicker(time.Minute)
|
t := time.NewTicker(time.Minute)
|
||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
|
|
||||||
@@ -269,6 +270,7 @@ func StartLooking(ctx context.Context, lookingPath string) {
|
|||||||
//统计文件行数
|
//统计文件行数
|
||||||
fileLines := make(map[string]int)
|
fileLines := make(map[string]int)
|
||||||
AddLog(fmt.Sprintf("正在统计 %v 个文件行数", len(files)))
|
AddLog(fmt.Sprintf("正在统计 %v 个文件行数", len(files)))
|
||||||
|
isAllEmpty := true
|
||||||
for _, filePath := range files {
|
for _, filePath := range files {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@@ -290,9 +292,16 @@ func StartLooking(ctx context.Context, lookingPath string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fileLines[filepath.Base(filePath)] = lineCount
|
fileLines[filepath.Base(filePath)] = lineCount
|
||||||
|
if lineCount != 0 {
|
||||||
|
isAllEmpty = false
|
||||||
|
}
|
||||||
AddLog(fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount))
|
AddLog(fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if isAllEmpty {
|
||||||
|
AddLog("所有文件都为空,不进行上传")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//添加任务
|
//添加任务
|
||||||
var tasks []Task
|
var tasks []Task
|
||||||
|
|||||||
Reference in New Issue
Block a user