|
|
@ -139,7 +139,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { |
|
|
|
|
|
|
|
|
|
|
|
private byte[] packChecksum; |
|
|
|
private byte[] packChecksum; |
|
|
|
|
|
|
|
|
|
|
|
private PackIndex loadedIdx; |
|
|
|
private volatile PackIndex loadedIdx; |
|
|
|
|
|
|
|
|
|
|
|
private PackReverseIndex reverseIdx; |
|
|
|
private PackReverseIndex reverseIdx; |
|
|
|
|
|
|
|
|
|
|
@ -174,35 +174,44 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { |
|
|
|
length = Long.MAX_VALUE; |
|
|
|
length = Long.MAX_VALUE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private synchronized PackIndex idx() throws IOException { |
|
|
|
private PackIndex idx() throws IOException { |
|
|
|
if (loadedIdx == null) { |
|
|
|
PackIndex idx = loadedIdx; |
|
|
|
if (invalid) |
|
|
|
if (idx == null) { |
|
|
|
throw new PackInvalidException(packFile); |
|
|
|
synchronized (this) { |
|
|
|
|
|
|
|
idx = loadedIdx; |
|
|
|
try { |
|
|
|
if (idx == null) { |
|
|
|
final PackIndex idx = PackIndex.open(extFile(INDEX)); |
|
|
|
if (invalid) { |
|
|
|
|
|
|
|
throw new PackInvalidException(packFile); |
|
|
|
if (packChecksum == null) { |
|
|
|
} |
|
|
|
packChecksum = idx.packChecksum; |
|
|
|
try { |
|
|
|
} else if (!Arrays.equals(packChecksum, idx.packChecksum)) { |
|
|
|
idx = PackIndex.open(extFile(INDEX)); |
|
|
|
throw new PackMismatchException(MessageFormat.format( |
|
|
|
|
|
|
|
JGitText.get().packChecksumMismatch, |
|
|
|
if (packChecksum == null) { |
|
|
|
packFile.getPath(), |
|
|
|
packChecksum = idx.packChecksum; |
|
|
|
ObjectId.fromRaw(packChecksum).name(), |
|
|
|
} else if (!Arrays.equals(packChecksum, |
|
|
|
ObjectId.fromRaw(idx.packChecksum).name())); |
|
|
|
idx.packChecksum)) { |
|
|
|
|
|
|
|
throw new PackMismatchException(MessageFormat |
|
|
|
|
|
|
|
.format(JGitText.get().packChecksumMismatch, |
|
|
|
|
|
|
|
packFile.getPath(), |
|
|
|
|
|
|
|
ObjectId.fromRaw(packChecksum) |
|
|
|
|
|
|
|
.name(), |
|
|
|
|
|
|
|
ObjectId.fromRaw(idx.packChecksum) |
|
|
|
|
|
|
|
.name())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
loadedIdx = idx; |
|
|
|
|
|
|
|
} catch (InterruptedIOException e) { |
|
|
|
|
|
|
|
// don't invalidate the pack, we are interrupted from
|
|
|
|
|
|
|
|
// another thread
|
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
invalid = true; |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
loadedIdx = idx; |
|
|
|
|
|
|
|
} catch (InterruptedIOException e) { |
|
|
|
|
|
|
|
// don't invalidate the pack, we are interrupted from another thread
|
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
invalid = true; |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return loadedIdx; |
|
|
|
return idx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the File object which locates this pack on disk. |
|
|
|
* Get the File object which locates this pack on disk. |
|
|
|
* |
|
|
|
* |
|
|
|