fix MediawikiImporter for bz2 dump

skip reading bz2 file magicbyte to identify bz2 format as inputstream reset would be required. Common compress reads and checks the magicbytes internally and throws ioexception if wrong, making preread obsolete.
pull/23/head
reger 10 years ago
parent c6687dd560
commit bbe9df2bb3

@ -153,16 +153,6 @@ public class MediawikiImporter extends Thread implements Importer {
if (p > 0) targetstub = targetstub.substring(0, p); if (p > 0) targetstub = targetstub.substring(0, p);
InputStream is = new BufferedInputStream(new FileInputStream(this.sourcefile), 1024 * 1024); InputStream is = new BufferedInputStream(new FileInputStream(this.sourcefile), 1024 * 1024);
if (this.sourcefile.getName().endsWith(".bz2")) { if (this.sourcefile.getName().endsWith(".bz2")) {
int b = is.read();
if (b != 'B') {
try {is.close();} catch (final IOException e) {}
throw new IOException("Invalid bz2 content.");
}
b = is.read();
if (b != 'Z') {
try {is.close();} catch (final IOException e) {}
throw new IOException("Invalid bz2 content.");
}
is = new BZip2CompressorInputStream(is); is = new BZip2CompressorInputStream(is);
} else if (this.sourcefile.getName().endsWith(".gz")) { } else if (this.sourcefile.getName().endsWith(".gz")) {
is = new GZIPInputStream(is); is = new GZIPInputStream(is);

Loading…
Cancel
Save