Browse Source

Refactor DefaultRemoteReader for easier code reuse

Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
stable-3.5
Yuxuan 'fishy' Wang 11 years ago
parent
commit
afa2154e45
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

10
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

@ -182,6 +182,15 @@ public class RepoCommand extends GitCommand<RevCommit> {
.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 class RepoCommand extends GitCommand<RevCommit> {
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…
Cancel
Save