Refactor DefaultRemoteReader for easier code reuse
Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
This commit is contained in:
parent
83846d1f6d
commit
afa2154e45
|
@ -182,6 +182,15 @@ public byte[] readFile(String uri, String ref, String path)
|
||||||
.setURI(uri)
|
.setURI(uri)
|
||||||
.call()
|
.call()
|
||||||
.getRepository();
|
.getRepository();
|
||||||
|
try {
|
||||||
|
return readFileFromRepo(repo, ref, path);
|
||||||
|
} finally {
|
||||||
|
FileUtils.delete(dir, FileUtils.RECURSIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected byte[] readFileFromRepo(Repository repo,
|
||||||
|
String ref, String path) throws GitAPIException, IOException {
|
||||||
ObjectReader reader = repo.newObjectReader();
|
ObjectReader reader = repo.newObjectReader();
|
||||||
byte[] result;
|
byte[] result;
|
||||||
try {
|
try {
|
||||||
|
@ -189,7 +198,6 @@ public byte[] readFile(String uri, String ref, String path)
|
||||||
result = reader.open(oid).getBytes(Integer.MAX_VALUE);
|
result = reader.open(oid).getBytes(Integer.MAX_VALUE);
|
||||||
} finally {
|
} finally {
|
||||||
reader.release();
|
reader.release();
|
||||||
FileUtils.delete(dir, FileUtils.RECURSIVE);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue