From 3eeef1f2f18cb497e1da872efecf667eddb6caee Mon Sep 17 00:00:00 2001 From: xc Date: Sun, 28 Sep 2025 11:28:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4rpc=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scagent/core/FileRpc.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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(),