* @param blockInfo The block to be added
* @throws BlockInfoException
*/
public synchronized void addBlock(BlockInfo blockInfo) throws BlockInfoException {
if (mIsComplete) {
throw new BlockInfoException("The file is complete: " + this);
}
if (mBlocks.size() > 0 && mBlocks.get(mBlocks.size() - 1).mLength != mBlockSizeByte) {
throw new BlockInfoException("mBlockSizeByte is " + mBlockSizeByte + ", but the "
+ "previous block size is " + mBlocks.get(mBlocks.size() - 1).mLength);
}
if (blockInfo.getInodeFile() != this) {
throw new BlockInfoException("InodeFile unmatch: " + this + " != " + blockInfo);
}
if (blockInfo.mBlockIndex != mBlocks.size()) {
throw new BlockInfoException("BLOCK_INDEX unmatch: " + mBlocks.size() + " != " + blockInfo);
}
if (blockInfo.mOffset != mBlocks.size() * mBlockSizeByte) {
throw new BlockInfoException("OFFSET unmatch: " + mBlocks.size() * mBlockSizeByte + " != "
+ blockInfo);
}
if (blockInfo.mLength > mBlockSizeByte) {
throw new BlockInfoException("LENGTH too big: " + mBlockSizeByte + " " + blockInfo);
}
mLength += blockInfo.mLength;
mBlocks.add(blockInfo);
}