diff options
| author | Dariusz Luksza | 2010-08-16 19:06:04 +0000 |
|---|---|---|
| committer | Dariusz Luksza | 2010-08-16 19:06:04 +0000 |
| commit | 6ef63719a7e8c53b7627da17248398226f158b77 (patch) | |
| tree | 4773aa8f9d2a70d2a20772364e2c2cc040a9d4f0 | |
| parent | 68d6e348c069d07d60a8ad44daf9aa6d93f55635 (diff) | |
| download | egit-6ef63719a7e8c53b7627da17248398226f158b77.tar.gz egit-6ef63719a7e8c53b7627da17248398226f158b77.tar.xz egit-6ef63719a7e8c53b7627da17248398226f158b77.zip | |
Use InputStream instead of byte[] in GitBlobResourceVariant
Using ObjectLoader.getBytes() causes LargeObjectException when we were
dealing with object >1M use of ObjectLoader.openStream() should fix this
issue.
Bug: 322707
Change-Id: I58851193d50cef729333da12d556e345251c9e14
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
3 files changed, 11 insertions, 13 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitBlobResourceVariant.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitBlobResourceVariant.java index b9b3110ae9..f496b4931b 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitBlobResourceVariant.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitBlobResourceVariant.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.egit.core.synchronize; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -38,14 +37,13 @@ public class GitBlobResourceVariant extends GitResourceVariant { private IStorage storage; - private byte[] bytes; + private final ObjectLoader blob; GitBlobResourceVariant(Repository repo, ObjectId objectId, String path) throws IOException { super(repo, objectId, path); - ObjectLoader blob = repo.open(getObjectId()); - bytes = blob.getBytes(); + blob = repo.open(getObjectId()); } public boolean isContainer() { @@ -72,7 +70,11 @@ public class GitBlobResourceVariant extends GitResourceVariant { } public InputStream getContents() throws CoreException { - return new ByteArrayInputStream(bytes); + try { + return blob.openStream(); + } catch (IOException e) { + throw new TeamException(e.getMessage(), e); + } } public String getCharset() throws CoreException { @@ -95,8 +97,4 @@ public class GitBlobResourceVariant extends GitResourceVariant { return storage; } - public byte[] asBytes() { - return bytes; - } - } diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitFolderResourceVariant.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitFolderResourceVariant.java index 7c5ed8744c..c6af7efc3c 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitFolderResourceVariant.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitFolderResourceVariant.java @@ -50,10 +50,6 @@ public class GitFolderResourceVariant extends GitResourceVariant { return null; } - public byte[] asBytes() { - return getName().getBytes(); - } - /** * @param progress * @return members diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariant.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariant.java index aa1ecd83ab..3de52bfb48 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariant.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariant.java @@ -83,6 +83,10 @@ abstract class GitResourceVariant implements IResourceVariant { return false; } + public byte[] asBytes() { + return getObjectId().getName().getBytes(); + } + @Override public String toString() { return path + "(" + objectId.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ |
