|
|
@@ -44,6 +44,8 @@ |
|
|
|
|
|
|
|
package org.eclipse.jgit.transport; |
|
|
|
|
|
|
|
import static org.eclipse.jgit.transport.SideBandOutputStream.HDR_SIZE; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.regex.Matcher; |
|
|
@@ -69,7 +71,7 @@ import org.eclipse.jgit.util.RawParseUtils; |
|
|
|
* Channel 3 results in an exception being thrown, as the remote side has issued |
|
|
|
* an unrecoverable error. |
|
|
|
* |
|
|
|
* @see PacketLineIn#sideband(ProgressMonitor) |
|
|
|
* @see SideBandOutputStream |
|
|
|
*/ |
|
|
|
class SideBandInputStream extends InputStream { |
|
|
|
static final int CH_DATA = 1; |
|
|
@@ -84,9 +86,9 @@ class SideBandInputStream extends InputStream { |
|
|
|
private static Pattern P_BOUNDED = Pattern.compile( |
|
|
|
"^([\\w ]+):.*\\((\\d+)/(\\d+)\\).*", Pattern.DOTALL); |
|
|
|
|
|
|
|
private final PacketLineIn pckIn; |
|
|
|
private final InputStream rawIn; |
|
|
|
|
|
|
|
private final InputStream in; |
|
|
|
private final PacketLineIn pckIn; |
|
|
|
|
|
|
|
private final ProgressMonitor monitor; |
|
|
|
|
|
|
@@ -102,11 +104,10 @@ class SideBandInputStream extends InputStream { |
|
|
|
|
|
|
|
private int available; |
|
|
|
|
|
|
|
SideBandInputStream(final PacketLineIn aPckIn, final InputStream aIn, |
|
|
|
final ProgressMonitor aProgress) { |
|
|
|
pckIn = aPckIn; |
|
|
|
in = aIn; |
|
|
|
monitor = aProgress; |
|
|
|
SideBandInputStream(final InputStream in, final ProgressMonitor progress) { |
|
|
|
rawIn = in; |
|
|
|
pckIn = new PacketLineIn(rawIn); |
|
|
|
monitor = progress; |
|
|
|
currentTask = ""; |
|
|
|
} |
|
|
|
|
|
|
@@ -116,7 +117,7 @@ class SideBandInputStream extends InputStream { |
|
|
|
if (eof) |
|
|
|
return -1; |
|
|
|
available--; |
|
|
|
return in.read(); |
|
|
|
return rawIn.read(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -126,7 +127,7 @@ class SideBandInputStream extends InputStream { |
|
|
|
needDataPacket(); |
|
|
|
if (eof) |
|
|
|
break; |
|
|
|
final int n = in.read(b, off, Math.min(len, available)); |
|
|
|
final int n = rawIn.read(b, off, Math.min(len, available)); |
|
|
|
if (n < 0) |
|
|
|
break; |
|
|
|
r += n; |
|
|
@@ -147,8 +148,8 @@ class SideBandInputStream extends InputStream { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
channel = in.read(); |
|
|
|
available -= 5; // length header plus channel indicator |
|
|
|
channel = rawIn.read(); |
|
|
|
available -= HDR_SIZE; // length header plus channel indicator |
|
|
|
if (available == 0) |
|
|
|
continue; |
|
|
|
|
|
|
@@ -157,7 +158,6 @@ class SideBandInputStream extends InputStream { |
|
|
|
return; |
|
|
|
case CH_PROGRESS: |
|
|
|
progress(readString(available)); |
|
|
|
|
|
|
|
continue; |
|
|
|
case CH_ERROR: |
|
|
|
eof = true; |
|
|
@@ -229,7 +229,7 @@ class SideBandInputStream extends InputStream { |
|
|
|
|
|
|
|
private String readString(final int len) throws IOException { |
|
|
|
final byte[] raw = new byte[len]; |
|
|
|
IO.readFully(in, raw, 0, len); |
|
|
|
IO.readFully(rawIn, raw, 0, len); |
|
|
|
return RawParseUtils.decode(Constants.CHARSET, raw, 0, len); |
|
|
|
} |
|
|
|
} |