代码拉取完成,页面将自动刷新
同步操作将从 ttpc2008/BaiduPCS-Go 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package uploader
import (
"io"
)
type (
// BlockState 文件区块信息
BlockState struct {
ID int `json:"id"`
Range ReadRange `json:"range"`
CheckSum string `json:"checksum"`
}
// InstanceState 上传断点续传信息
InstanceState struct {
BlockList []*BlockState `json:"block_list"`
}
)
func workerListToInstanceState(workers workerList) *InstanceState {
blockStates := make([]*BlockState, 0, len(workers))
for _, wer := range workers {
blockStates = append(blockStates, &BlockState{
ID: wer.id,
Range: wer.splitUnit.Range(),
CheckSum: wer.checksum,
})
}
return &InstanceState{
BlockList: blockStates,
}
}
func instanceStateToWorkerList(is *InstanceState, file io.ReaderAt) workerList {
workers := make(workerList, 0, len(is.BlockList))
for _, blockState := range is.BlockList {
if blockState.CheckSum == "" {
workers = append(workers, &worker{
id: blockState.ID,
partOffset: blockState.Range.Begin,
splitUnit: NewSplitUnit(file, blockState.Range),
checksum: blockState.CheckSum,
})
} else {
workers = append(workers, &worker{
id: blockState.ID,
partOffset: blockState.Range.Begin,
splitUnit: &fileBlock{
readRange: blockState.Range,
readed: blockState.Range.End - blockState.Range.Begin,
readerAt: file,
},
checksum: blockState.CheckSum,
})
}
}
return workers
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。