(hash string)
| 275 | } |
| 276 | |
| 277 | func (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 | |
| 311 | func (this *FS) openBFile(bPath string, bName string) (*BlocksFile, error) { |
| 312 | // check closing queue |
no test coverage detected