Browse Source

调整rpc传输文件的函数

master
xyiege 4 months ago
parent
commit
3eeef1f2f1
  1. 10
      scagent/core/FileRpc.go

10
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(),

Loading…
Cancel
Save