MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / WriteBodyBlockUnsafe

Method WriteBodyBlockUnsafe

internal/utils/bfs/meta_file.go:141–163  ·  view source on GitHub ↗
(hash string, bOffsetFrom int64, bOffsetTo int64, originOffsetFrom int64, originOffsetTo int64)

Source from the content-addressed store, hash-verified

139}
140
141func (this *MetaFile) WriteBodyBlockUnsafe(hash string, bOffsetFrom int64, bOffsetTo int64, originOffsetFrom int64, originOffsetTo int64) error {
142 lazyHeader, ok := this.headerMap[hash]
143 if !ok {
144 return nil
145 }
146
147 header, err := lazyHeader.FileHeaderUnsafe()
148 if err != nil {
149 return err
150 }
151
152 // TODO 合并相邻block
153 header.BodyBlocks = append(header.BodyBlocks, BlockInfo{
154 OriginOffsetFrom: originOffsetFrom,
155 OriginOffsetTo: originOffsetTo,
156 BFileOffsetFrom: bOffsetFrom,
157 BFileOffsetTo: bOffsetTo,
158 })
159
160 this.modifiedHashMap[hash] = zero.Zero{}
161
162 return nil
163}
164
165func (this *MetaFile) WriteClose(hash string, headerSize int64, bodySize int64) error {
166 // TODO 考虑单个hash多次重复调用的情况

Callers 3

TestMetaFile_WriteMetaFunction · 0.80
TestMetaFile_WriteFunction · 0.80
WriteMethod · 0.80

Calls 1

FileHeaderUnsafeMethod · 0.45

Tested by 2

TestMetaFile_WriteMetaFunction · 0.64
TestMetaFile_WriteFunction · 0.64