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

Method openBFileForHashWriting

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

Source from the content-addressed store, hash-verified

240}
241
242func (this *FS) openBFileForHashWriting(hash string) (*BlocksFile, error) {
243 err := CheckHashErr(hash)
244 if err != nil {
245 return nil, err
246 }
247
248 bPath, bName, err := this.bPathForHash(hash)
249 if err != nil {
250 return nil, err
251 }
252
253 this.mu.RLock()
254 bFile, ok := this.bMap[bName]
255 this.mu.RUnlock()
256 if ok {
257 // 调整当前BFile所在位置
258 this.mu.Lock()
259
260 if bFile.IsClosing() {
261 // TODO 需要重新等待打开
262 }
263
264 item, itemOk := this.bItemMap[bName]
265 if itemOk {
266 this.bList.Remove(item)
267 this.bList.Push(item)
268 }
269 this.mu.Unlock()
270
271 return bFile, nil
272 }
273
274 return this.openBFile(bPath, bName)
275}
276
277func (this *FS) openBFileForHashReading(hash string) (*BlocksFile, error) {
278 err := CheckHashErr(hash)

Callers 2

OpenFileWriterMethod · 0.95
RemoveFileMethod · 0.95

Calls 10

bPathForHashMethod · 0.95
openBFileMethod · 0.95
CheckHashErrFunction · 0.85
RLockMethod · 0.80
RUnlockMethod · 0.80
IsClosingMethod · 0.80
RemoveMethod · 0.65
LockMethod · 0.45
PushMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected