瀏覽代碼

dfs: handle short copies

`copy` is documented as possibly returning a smaller number of bytes
than requested. In practice, this can occur if a block is cached and the
reader never pulls in the file to check its size.

Bug: 565874
Change-Id: I1e53b3d2f4ab09334178934dc0ef74ea99045cd3
Signed-off-by: wh <wh9692@protonmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v5.11.0.202102240950-m3
wh 3 年之前
父節點
當前提交
a14455dfd7
共有 1 個檔案被更改,包括 9 行新增2 行删除
  1. 9
    2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java

+ 9
- 2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java 查看文件

@@ -607,8 +607,15 @@ public final class DfsPackFile extends BlockBasedFile {

private void readFully(long position, byte[] dstbuf, int dstoff, int cnt,
DfsReader ctx) throws IOException {
if (ctx.copy(this, position, dstbuf, dstoff, cnt) != cnt)
throw new EOFException();
while (cnt > 0) {
int copied = ctx.copy(this, position, dstbuf, dstoff, cnt);
if (copied == 0) {
throw new EOFException();
}
position += copied;
dstoff += copied;
cnt -= copied;
}
}

ObjectLoader load(DfsReader ctx, long pos)

Loading…
取消
儲存