|
@@ -321,7 +321,16 @@ func (a *Access) chunkUpgrade(params rpcs.ChunkUpgrade) error {
|
|
|
if fileReply.File == nil {
|
|
|
return errors.New(fmt.Sprintf("文件:%s 获取失败", params.FileId))
|
|
|
}
|
|
|
- buf.Write(fileReply.File[params.Offset*int(params.Size) : (params.Offset+1)+int(params.Size)])
|
|
|
+ start := params.Offset * int(params.Size)
|
|
|
+ stop := (params.Offset + 1) + int(params.Size)
|
|
|
+ if stop >= len(fileArgs.FileData) {
|
|
|
+ stop = len(fileArgs.FileData)
|
|
|
+ }
|
|
|
+ data := fileReply.File[start:stop]
|
|
|
+ buf.Write(gbinary.BeEncodeUint16(gconv.Uint16(len(data))))
|
|
|
+ buf.Write(data)
|
|
|
+ // 生成随机的4位数字
|
|
|
+ //randomNumber := rand.Intn(9000) + 1000
|
|
|
server.Log.Infof("1----------填充文件:%2X", buf.Bytes())
|
|
|
var mCrc crc
|
|
|
checkSum := mCrc.reset().pushBytes(buf.Bytes()).value()
|