Browse Source

Remove unnecessary truncation of in-pack size during copy

The number of bytes to copy was truncated to an int, but the
pack's copyToStream() method expected to be passed a long here.
Pass through the long so we don't truncate a giant object.

Change-Id: I0786ad60a3a33f84d8746efe51f68d64e127c332
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
tags/v0.8.1
Shawn O. Pearce 14 years ago
parent
commit
ae972e774e
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/lib/PackFile.java View File

throws IOException { throws IOException {
final long objectOffset = loader.objectOffset; final long objectOffset = loader.objectOffset;
final long dataOffset = objectOffset + loader.headerSize; final long dataOffset = objectOffset + loader.headerSize;
final int cnt = (int) (findEndOffset(objectOffset) - dataOffset);
final long sz = findEndOffset(objectOffset) - dataOffset;
final PackIndex idx = idx(); final PackIndex idx = idx();


if (idx.hasCRC32Support()) { if (idx.hasCRC32Support()) {
headerCnt -= toRead; headerCnt -= toRead;
} }
final CheckedOutputStream crcOut = new CheckedOutputStream(out, crc); final CheckedOutputStream crcOut = new CheckedOutputStream(out, crc);
copyToStream(dataOffset, buf, cnt, crcOut, curs);
copyToStream(dataOffset, buf, sz, crcOut, curs);
final long computed = crc.getValue(); final long computed = crc.getValue();


final ObjectId id = findObjectForOffset(objectOffset); final ObjectId id = findObjectForOffset(objectOffset);
coe.initCause(dfe); coe.initCause(dfe);
throw coe; throw coe;
} }
copyToStream(dataOffset, buf, cnt, out, curs);
copyToStream(dataOffset, buf, sz, out, curs);
} }
} }



Loading…
Cancel
Save