public int GetLength(Hash hash) { // Cache { int length = _blocksManager.GetLength(hash); if (length != 0) { return(length); } } // Share { lock (_lockObject) { var shareInfo = _contentInfoManager.GetShareInfo(hash); if (shareInfo != null) { return((int)Math.Min(shareInfo.FileLength - ((long)shareInfo.BlockLength * shareInfo.GetIndex(hash)), shareInfo.BlockLength)); } } } return(0); }
public int GetLength(Hash hash) { { int length = _blocksManager.GetLength(hash); if (length != 0) { return(length); } } { int length = 0; using (_lockManager.ReadLock()) { var shareInfo = _contentInfoManager.GetShareInfo(hash); if (shareInfo != null) { length = Math.Min((int)(shareInfo.FileLength - (shareInfo.BlockLength * shareInfo.GetIndex(hash))), shareInfo.BlockLength); } } if (length != 0) { return(length); } } return(0); }