|
|
|
@@ -9,7 +9,7 @@ import ( |
|
|
|
"gitlink.org.cn/cloudream/agent/internal/config" |
|
|
|
"gitlink.org.cn/cloudream/utils" |
|
|
|
|
|
|
|
racli "gitlink.org.cn/cloudream/rabbitmq/client" |
|
|
|
coorcli "gitlink.org.cn/cloudream/rabbitmq/client/coordinator" |
|
|
|
ramsg "gitlink.org.cn/cloudream/rabbitmq/message" |
|
|
|
agtmsg "gitlink.org.cn/cloudream/rabbitmq/message/agent" |
|
|
|
coormsg "gitlink.org.cn/cloudream/rabbitmq/message/coordinator" |
|
|
|
@@ -59,6 +59,14 @@ func (service *CommandService) RepMove(msg *agtmsg.RepMoveCommand) *agtmsg.Agent |
|
|
|
for { |
|
|
|
readCnt, err := ipfsRd.Read(buf) |
|
|
|
|
|
|
|
if readCnt > 0 { |
|
|
|
err = myio.WriteAll(outFile, buf[:readCnt]) |
|
|
|
if err != nil { |
|
|
|
log.Warnf("write data to file %s failed, err: %s", outFilePath, err.Error()) |
|
|
|
return ramsg.ReplyFailed[agtmsg.AgentMoveResp](errorcode.OPERATION_FAILED, "write data to file failed") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 文件读取完毕 |
|
|
|
if err == io.EOF { |
|
|
|
break |
|
|
|
@@ -68,16 +76,10 @@ func (service *CommandService) RepMove(msg *agtmsg.RepMoveCommand) *agtmsg.Agent |
|
|
|
log.Warnf("read ipfs file %s data failed, err: %s", fileHash, err.Error()) |
|
|
|
return ramsg.ReplyFailed[agtmsg.AgentMoveResp](errorcode.OPERATION_FAILED, "read ipfs file data failed") |
|
|
|
} |
|
|
|
|
|
|
|
err = myio.WriteAll(outFile, buf[:readCnt]) |
|
|
|
if err != nil { |
|
|
|
log.Warnf("write data to file %s failed, err: %s", outFilePath, err.Error()) |
|
|
|
return ramsg.ReplyFailed[agtmsg.AgentMoveResp](errorcode.OPERATION_FAILED, "write data to file failed") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//向coor报告临时缓存hash |
|
|
|
coorClient, err := racli.NewCoordinatorClient() |
|
|
|
coorClient, err := coorcli.NewCoordinatorClient(&config.Cfg().RabbitMQ) |
|
|
|
if err != nil { |
|
|
|
log.Warnf("new coordinator client failed, err: %s", err.Error()) |
|
|
|
return ramsg.ReplyFailed[agtmsg.AgentMoveResp](errorcode.OPERATION_FAILED, "new coordinator client failed") |
|
|
|
|