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)
|
||||
.call()
|
||||
.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();
|
||||
byte[] result;
|
||||
try {
|
||||
|
@ -189,7 +198,6 @@ public byte[] readFile(String uri, String ref, String path)
|
|||
result = reader.open(oid).getBytes(Integer.MAX_VALUE);
|
||||
} finally {
|
||||
reader.release();
|
||||
FileUtils.delete(dir, FileUtils.RECURSIVE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue