MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / openBFileForHashReading

Method openBFileForHashReading

internal/utils/bfs/fs.go:277–309  ·  view source on GitHub ↗
(hash string)

Source from the content-addressed store, hash-verified

275}
276
277func (this *FS) openBFileForHashReading(hash string) (*BlocksFile, error) {
278 err := CheckHashErr(hash)
279 if err != nil {
280 return nil, err
281 }
282
283 bPath, bName, err := this.bPathForHash(hash)
284 if err != nil {
285 return nil, err
286 }
287
288 err = this.waitBFile(bPath)
289 if err != nil {
290 return nil, err
291 }
292
293 this.mu.Lock()
294 bFile, ok := this.bMap[bName]
295 if ok {
296 // 调整当前BFile所在位置
297 item, itemOk := this.bItemMap[bName]
298 if itemOk {
299 this.bList.Remove(item)
300 this.bList.Push(item)
301 }
302 this.mu.Unlock()
303 return bFile, nil
304 }
305
306 this.mu.Unlock()
307
308 return this.openBFile(bPath, bName)
309}
310
311func (this *FS) openBFile(bPath string, bName string) (*BlocksFile, error) {
312 // check closing queue

Callers 2

OpenFileReaderMethod · 0.95
ExistFileMethod · 0.95

Calls 8

bPathForHashMethod · 0.95
waitBFileMethod · 0.95
openBFileMethod · 0.95
CheckHashErrFunction · 0.85
RemoveMethod · 0.65
LockMethod · 0.45
PushMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected