else if(logMINOR)
Logger.minor(this, "Container size (possibly compressed): "+archiveSize+" for "+data);
InputStream is = null;
try {
final ExceptionWrapper wrapper;
if((ctype == null) || (ARCHIVE_TYPE.ZIP == archiveType)) {
if(logMINOR) Logger.minor(this, "No compression");
is = data.getInputStream();
wrapper = null;
} else if(ctype == COMPRESSOR_TYPE.BZIP2) {
if(logMINOR) Logger.minor(this, "dealing with BZIP2");
is = new BZip2CompressorInputStream(data.getInputStream());
wrapper = null;
} else if(ctype == COMPRESSOR_TYPE.GZIP) {
if(logMINOR) Logger.minor(this, "dealing with GZIP");
is = new GZIPInputStream(data.getInputStream());
wrapper = null;
} else if(ctype == COMPRESSOR_TYPE.LZMA_NEW) {
// LZMA internally uses pipe streams, so we may as well do it here.
// In fact we need to for LZMA_NEW, because of the properties bytes.
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream();
pis.connect(pos);
final OutputStream os = new BufferedOutputStream(pos);
wrapper = new ExceptionWrapper();
context.mainExecutor.execute(new Runnable() {
@Override
public void run() {
InputStream is = null;
try {
Compressor.COMPRESSOR_TYPE.LZMA_NEW.decompress(is = data.getInputStream(), os, data.size(), expectedSize);
} catch (CompressionOutputSizeException e) {
Logger.error(this, "Failed to decompress archive: "+e, e);
wrapper.set(e);
} catch (IOException e) {
Logger.error(this, "Failed to decompress archive: "+e, e);
wrapper.set(e);
} finally {
try {
os.close();
} catch (IOException e) {
Logger.error(this, "Failed to close PipedOutputStream: "+e, e);
}
Closer.close(is);
}
}
});
is = pis;
} else if(ctype == COMPRESSOR_TYPE.LZMA) {
if(logMINOR) Logger.minor(this, "dealing with LZMA");
is = new LzmaInputStream(data.getInputStream());
wrapper = null;
} else {
wrapper = null;
}
if(ARCHIVE_TYPE.ZIP == archiveType)
handleZIPArchive(ctx, key, is, element, callback, gotElement, throwAtExit, context);
else if(ARCHIVE_TYPE.TAR == archiveType)
handleTARArchive(ctx, key, is, element, callback, gotElement, throwAtExit, context);
else
throw new ArchiveFailureException("Unknown or unsupported archive algorithm " + archiveType);
if(wrapper != null) {
Exception e = wrapper.get();
if(e != null) throw new ArchiveFailureException("An exception occured decompressing: "+e.getMessage(), e);
}
} catch (IOException ioe) {
throw new ArchiveFailureException("An IOE occured: "+ioe.getMessage(), ioe);
}finally {