diff --git a/.gitea/workflows/build_tool.yaml b/.gitea/workflows/build_tool.yaml index 89a654a..757ae74 100644 --- a/.gitea/workflows/build_tool.yaml +++ b/.gitea/workflows/build_tool.yaml @@ -52,9 +52,11 @@ jobs: - name: 构建上传工具 run: | set -x + git_hash=$(git rev-parse --short "$GITHUB_SHA") + build_date=$(TZ=Asia/Shanghai date +"%Y%m%d%H%M") wails build \ -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 - name: 上传构建文件 diff --git a/internal/uploader/uploader.go b/internal/uploader/uploader.go index 8d17d44..25d12c1 100644 --- a/internal/uploader/uploader.go +++ b/internal/uploader/uploader.go @@ -118,7 +118,6 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) { fileLines[filepath.Base(filePath)] = lineCount isAllEmpty = false 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 { @@ -126,10 +125,12 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) { return } + progress.Clear() //添加文件上传任务参数(文件路径,文件行数) var tasks []Task - for k, v := range fileLines { - tasks = append(tasks, Task{FilePath: path + "/" + k, FileLines: v}) + for fileName, lines := range fileLines { + tasks = append(tasks, Task{FilePath: path + "/" + fileName, FileLines: lines}) + progress.Store(fileName, Progress{FileName: fileName, Total: lines, Uploaded: 0, Percentage: 0}) } // 使用 errgroup 控制同时处理的文件数,并开始上传文件任务 @@ -178,7 +179,6 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) { } AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String())) - progress.Clear() } }