Do not attempt to read bitmap from invalid pack

If a pack file has been marked invalid due to a prior IOException
accessing its contents, do not offer its bitmap index to callers.
The pack cannot be used so its bitmap should be off limits from
any reader trying to work from a bitmap.

Change-Id: Ia44e46558abdddee560bb184158b1e0af9437eee
This commit is contained in:
Shawn Pearce 2013-03-06 12:48:25 -08:00
parent 88c962484f
commit 913cccd5c4
2 changed files with 4 additions and 0 deletions

View File

@ -277,6 +277,8 @@ else if (bs <= 0)
}
PackBitmapIndex getBitmapIndex(DfsReader ctx) throws IOException {
if (invalid)
return null;
DfsBlockCache.Ref<PackBitmapIndex> idxref = bitmapIndex;
if (idxref != null) {
PackBitmapIndex idx = idxref.get();

View File

@ -1057,6 +1057,8 @@ private long findEndOffset(final long startOffset)
}
synchronized PackBitmapIndex getBitmapIndex() throws IOException {
if (invalid)
return null;
if (bitmapIdx == null && hasExt(BITMAP_INDEX)) {
final PackBitmapIndex idx = PackBitmapIndex.open(
extFile(BITMAP_INDEX), idx(), getReverseIdx());