Skip to content

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

fix tarParser early exit on looping content - adjust check of data available according to doc - return null on no recognized content (to not exit TextParser next parser try) - use commons.compress directly

reger5d71fc70e3f2
diff --git a/source/net/yacy/document/parser/tarParser.java b/source/net/yacy/document/parser/tarParser.java
index 52a84e296..be4b515fd 100644
--- a/source/net/yacy/document/parser/tarParser.java
+++ b/source/net/yacy/document/parser/tarParser.java
@@ -43,8 +43,8 @@ import net.yacy.document.TextParser;
import net.yacy.document.VocabularyScraper;
import net.yacy.kelondro.util.FileUtils;
-import org.apache.tools.tar.TarEntry;
-import org.apache.tools.tar.TarInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
// this is a new implementation of this parser idiom using multiple documents as result set
@@ -80,15 +80,14 @@ public class tarParser extends AbstractParser implements Parser {
throw new Parser.Failure("tar parser: " + e.getMessage(), location);
}
}
- TarEntry entry;
- final TarInputStream tis = new TarInputStream(source);
+ TarArchiveEntry entry;
+ final TarArchiveInputStream tis = new TarArchiveInputStream(source);
File tmp = null;
// loop through the elements in the tar file and parse every single file inside
while (true) {
try {
- if (tis.available() <= 0) break;
- entry = tis.getNextEntry();
+ entry = tis.getNextTarEntry();
if (entry == null) break;
if (entry.isDirectory() || entry.getSize() <= 0) continue;
final String name = entry.getName();
@@ -110,6 +109,7 @@ public class tarParser extends AbstractParser implements Parser {
break;
}
}
+ if (docacc.isEmpty()) return null;
return docacc.toArray(new Document[docacc.size()]);
}