- 在 UploadDataToServer 函数中添加 context 参数支持 - 使用 http.NewRequest 替换 httpClient.Post 以更好地控制请求上下文 - 重构应用启动逻辑,在 StartUpload 中初始化上传器上下文 - 优化 StopUpload 方法中的上下文取消机制 - 移除上传过程中的 wg.Wait() 调用以改善并发性能
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user