fix unable to transfer file

This commit is contained in:
2026-02-07 14:40:58 +08:00
parent ed2629cb08
commit eb23ef9d5d
6 changed files with 64 additions and 8 deletions

View File

@@ -35,7 +35,6 @@ func (s *Service) SendFile(target *discovery.Peer, targetIP string, filePath str
slog.Error("Failed to open file", "path", filePath, "error", err, "component", "transfer-client")
return
}
defer file.Close()
stat, err := file.Stat()
if err != nil {
@@ -54,6 +53,7 @@ func (s *Service) SendFile(target *discovery.Peer, targetIP string, filePath str
s.StoreTransferToList(task)
go func() {
defer file.Close()
// 任务结束后清理 ctx
defer func() {
s.cancelMap.Delete(taskID)