- 在处理文件前先清除之前的进度记录 - 将循环变量名从 k, v 更改为 fileName, lines 提高可读性 - 移动进度初始化位置确保每个文件都有正确的进度跟踪 - 删除重复的进度清除操作避免潜在的数据丢失问题
This commit is contained in:
@@ -52,9 +52,11 @@ jobs:
|
|||||||
- name: 构建上传工具
|
- name: 构建上传工具
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||||
|
build_date=$(TZ=Asia/Shanghai date +"%Y%m%d%H%M")
|
||||||
wails build \
|
wails build \
|
||||||
-platform windows/amd64 \
|
-platform windows/amd64 \
|
||||||
-ldflags "-X 'main.version=$(TZ=Asia/Shanghai date +"%m%d%H%M")'" \
|
-ldflags "-X 'main.version=$build_date-$git_hash'" \
|
||||||
-o 上传工具.exe
|
-o 上传工具.exe
|
||||||
|
|
||||||
- name: 上传构建文件
|
- name: 上传构建文件
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
|
|||||||
fileLines[filepath.Base(filePath)] = lineCount
|
fileLines[filepath.Base(filePath)] = lineCount
|
||||||
isAllEmpty = false
|
isAllEmpty = false
|
||||||
AddLog(logChan, fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount))
|
AddLog(logChan, fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount))
|
||||||
progress.Store(filepath.Base(filePath), Progress{FileName: filepath.Base(filePath), Total: lineCount, Uploaded: 0, Percentage: 0})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if isAllEmpty {
|
if isAllEmpty {
|
||||||
@@ -126,10 +125,12 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress.Clear()
|
||||||
//添加文件上传任务参数(文件路径,文件行数)
|
//添加文件上传任务参数(文件路径,文件行数)
|
||||||
var tasks []Task
|
var tasks []Task
|
||||||
for k, v := range fileLines {
|
for fileName, lines := range fileLines {
|
||||||
tasks = append(tasks, Task{FilePath: path + "/" + k, FileLines: v})
|
tasks = append(tasks, Task{FilePath: path + "/" + fileName, FileLines: lines})
|
||||||
|
progress.Store(fileName, Progress{FileName: fileName, Total: lines, Uploaded: 0, Percentage: 0})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 errgroup 控制同时处理的文件数,并开始上传文件任务
|
// 使用 errgroup 控制同时处理的文件数,并开始上传文件任务
|
||||||
@@ -178,7 +179,6 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String()))
|
AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String()))
|
||||||
progress.Clear()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user