HADOOP-15962. The buffer size is small when unpacking tar archives. Contributed by BELUGA BEHR.
This commit is contained in:
parent
d8f670ff28
commit
57198bc511
@ -918,12 +918,13 @@ static void unTarUsingJava(File inFile, File untarDir,
|
||||
TarArchiveInputStream tis = null;
|
||||
try {
|
||||
if (gzipped) {
|
||||
inputStream = new BufferedInputStream(new GZIPInputStream(
|
||||
new FileInputStream(inFile)));
|
||||
inputStream = new GZIPInputStream(new FileInputStream(inFile));
|
||||
} else {
|
||||
inputStream = new BufferedInputStream(new FileInputStream(inFile));
|
||||
inputStream = new FileInputStream(inFile);
|
||||
}
|
||||
|
||||
inputStream = new BufferedInputStream(inputStream);
|
||||
|
||||
tis = new TarArchiveInputStream(inputStream);
|
||||
|
||||
for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
|
||||
@ -940,13 +941,9 @@ private static void unTarUsingJava(InputStream inputStream, File untarDir,
|
||||
TarArchiveInputStream tis = null;
|
||||
try {
|
||||
if (gzipped) {
|
||||
inputStream = new BufferedInputStream(new GZIPInputStream(
|
||||
inputStream));
|
||||
} else {
|
||||
inputStream =
|
||||
new BufferedInputStream(inputStream);
|
||||
inputStream = new GZIPInputStream(inputStream);
|
||||
}
|
||||
|
||||
inputStream = new BufferedInputStream(inputStream);
|
||||
tis = new TarArchiveInputStream(inputStream);
|
||||
|
||||
for (TarArchiveEntry entry = tis.getNextTarEntry(); entry != null;) {
|
||||
@ -1002,17 +999,7 @@ private static void unpackEntries(TarArchiveInputStream tis,
|
||||
return;
|
||||
}
|
||||
|
||||
int count;
|
||||
byte data[] = new byte[2048];
|
||||
try (BufferedOutputStream outputStream = new BufferedOutputStream(
|
||||
new FileOutputStream(outputFile));) {
|
||||
|
||||
while ((count = tis.read(data)) != -1) {
|
||||
outputStream.write(data, 0, count);
|
||||
}
|
||||
|
||||
outputStream.flush();
|
||||
}
|
||||
org.apache.commons.io.FileUtils.copyToFile(tis, outputFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user