mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 04:42:06 +01:00
Fix SOP armor command
This commit is contained in:
parent
c234e38ae2
commit
b76172f97a
1 changed files with 10 additions and 5 deletions
|
@ -51,12 +51,17 @@ public class Armor implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try (PushbackInputStream pbIn = new PushbackInputStream(System.in);
|
try (PushbackInputStream pbIn = new PushbackInputStream(System.in, BEGIN_ARMOR.length);
|
||||||
ArmoredOutputStream armoredOutputStream = ArmoredOutputStreamFactory.get(System.out)) {
|
ArmoredOutputStream armoredOutputStream = ArmoredOutputStreamFactory.get(System.out)) {
|
||||||
byte[] start = new byte[14];
|
|
||||||
int read = pbIn.read(start);
|
// take a peek
|
||||||
pbIn.unread(read);
|
byte[] firstBytes = new byte[BEGIN_ARMOR.length];
|
||||||
if (Arrays.equals(BEGIN_ARMOR, start) && !allowNested) {
|
int readByteCount = pbIn.read(firstBytes);
|
||||||
|
if (readByteCount != -1) {
|
||||||
|
pbIn.unread(firstBytes, 0, readByteCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arrays.equals(BEGIN_ARMOR, firstBytes) && !allowNested) {
|
||||||
Streams.pipeAll(pbIn, System.out);
|
Streams.pipeAll(pbIn, System.out);
|
||||||
} else {
|
} else {
|
||||||
Streams.pipeAll(pbIn, armoredOutputStream);
|
Streams.pipeAll(pbIn, armoredOutputStream);
|
||||||
|
|
Loading…
Reference in a new issue