refactor(uploader): 优化上传功能的上下文管理和并发控制
构建上传工具 / build-tool (push) Successful in 1m16s

- 在 UploadDataToServer 函数中添加 context 参数支持
- 使用 http.NewRequest 替换 httpClient.Post 以更好地控制请求上下文
- 重构应用启动逻辑,在 StartUpload 中初始化上传器上下文
- 优化 StopUpload 方法中的上下文取消机制
- 移除上传过程中的 wg.Wait() 调用以改善并发性能
This commit is contained in:
2026-04-27 13:38:14 +08:00
parent d44efeef8d
commit 987f0236a9
3 changed files with 14 additions and 6 deletions
+1 -1
View File
@@ -65,12 +65,12 @@ func (a *App) StartUpload() {
if isRun {
return
}
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
go uploader.StartLooking(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir)
}
func (a *App) StopUpload() {
if isRun {
a.uploaderCancel()
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
}
}