summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-12-03 11:20:28 -0500
committerJames Moger <james.moger@gitblit.com>2013-12-03 11:20:28 -0500
commit2a5e6510782fff7562fc2272a8483f4fa3c868c1 (patch)
treecadb391add72f84228bc3d7063b9a96fd2f678af /src
parent5842db3a8fa1c2e0a3163e535a9c20c09fdc6601 (diff)
downloadgitblit-2a5e6510782fff7562fc2272a8483f4fa3c868c1.tar.gz
gitblit-2a5e6510782fff7562fc2272a8483f4fa3c868c1.zip
Simplify blob loading code
Change-Id: I7f8ad8936e620dd06e88d85f6837248eea75a1ec
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/utils/JGitUtils.java27
1 files changed, 3 insertions, 24 deletions
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java
index 47799aab..212a90af 100644
--- a/src/main/java/com/gitblit/utils/JGitUtils.java
+++ b/src/main/java/com/gitblit/utils/JGitUtils.java
@@ -15,10 +15,8 @@
*/
package com.gitblit.utils;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -755,18 +753,8 @@ public class JGitUtils {
ObjectId entid = tw.getObjectId(0);
FileMode entmode = tw.getFileMode(0);
if (entmode != FileMode.GITLINK) {
- RevObject ro = rw.lookupAny(entid, entmode.getObjectType());
- rw.parseBody(ro);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- ObjectLoader ldr = repository.open(ro.getId(), Constants.OBJ_BLOB);
- byte[] tmp = new byte[4096];
- InputStream in = ldr.openStream();
- int n;
- while ((n = in.read(tmp)) > 0) {
- os.write(tmp, 0, n);
- }
- in.close();
- content = os.toByteArray();
+ ObjectLoader ldr = repository.open(entid, Constants.OBJ_BLOB);
+ content = ldr.getCachedBytes();
}
}
} catch (Throwable t) {
@@ -810,17 +798,8 @@ public class JGitUtils {
byte[] content = null;
try {
RevBlob blob = rw.lookupBlob(ObjectId.fromString(objectId));
- rw.parseBody(blob);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectLoader ldr = repository.open(blob.getId(), Constants.OBJ_BLOB);
- byte[] tmp = new byte[4096];
- InputStream in = ldr.openStream();
- int n;
- while ((n = in.read(tmp)) > 0) {
- os.write(tmp, 0, n);
- }
- in.close();
- content = os.toByteArray();
+ content = ldr.getCachedBytes();
} catch (Throwable t) {
error(t, repository, "{0} can't find blob {1}", objectId);
} finally {