diff --git a/scagent/core/FileRpc.go b/scagent/core/FileRpc.go index b79f7b4..c60a6ab 100644 --- a/scagent/core/FileRpc.go +++ b/scagent/core/FileRpc.go @@ -103,7 +103,7 @@ func clientUploadFile(remote string, filePath string, uploadPath string) { } defer client.rpcClient.Close() // 调用 transferFile - err = client.TransferFile(filePath, uploadPath) + err = transferFile(client, filePath, uploadPath) if err != nil { logger.Error("TransferFile failed", zap.Error(err)) fmt.Printf("TransferFile failed: %v\n", err) @@ -113,7 +113,7 @@ func clientUploadFile(remote string, filePath string, uploadPath string) { } // 传输文件 -func (c *UpFileClient) TransferFile(filePath string, uploadPath string) error { +func transferFile(client *UpFileClient, filePath string, uploadPath string) error { // 发送文件信息 fmt.Printf("TransferFile filePath: %s, uploadPath: %s\n", filePath, uploadPath) @@ -135,10 +135,12 @@ func (c *UpFileClient) TransferFile(filePath string, uploadPath string) error { fmt.Printf("remote dirpath: %s\n", dirpath) fmt.Printf("file size: %d\n", fileInfo.Size()) - // 发送文件信息 - var reply string + fmt.Printf("rpcClient: %v\n", c.rpcClient) + // 异步 go func() { + // 发送文件信息 + var reply string c.rpcClient.Call("UpFileService.SendFileInfo", FileInfo{ FileName: uploadPath, FileSize: fileInfo.Size(),