Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

untar files without gzip decompression even if the file has gz extension. this is done when the decompression fails. decompressed gzip files with gz extension may appear if the server sets a gzip compression header

orbiterac6b503adf42
diff --git a/source/de/anomic/tools/tarTools.java b/source/de/anomic/tools/tarTools.java
index 7ef0121c7..dc41c63a6 100644
--- a/source/de/anomic/tools/tarTools.java
+++ b/source/de/anomic/tools/tarTools.java
@@ -29,6 +29,7 @@ package de.anomic.tools;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
@@ -41,8 +42,17 @@ import org.apache.tools.tar.TarInputStream;
public class tarTools {
public static InputStream getInputStream(final String tarFileName) throws Exception{
- if(tarFileName.endsWith(".gz")){
- return new GZIPInputStream(new FileInputStream(new File(tarFileName)));
+ if (tarFileName.endsWith(".gz")) {
+ try {
+ return new GZIPInputStream(new FileInputStream(new File(tarFileName)));
+ } catch (IOException e) {
+ // this might happen if the stream is not in gzip format.
+ // there may be a 'gz' extension, but it may stil be a raw tar file
+ // this can be caused by 'one too much gzip-content header' that was attached
+ // by a release file server
+ // so just try to open is as normal stream
+ return new FileInputStream(new File(tarFileName));
+ }
}
return new FileInputStream(new File(tarFileName));
}