(hash string)
| 240 | } |
| 241 | |
| 242 | func (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 | |
| 277 | func (this *FS) openBFileForHashReading(hash string) (*BlocksFile, error) { |
| 278 | err := CheckHashErr(hash) |
no test coverage detected