Commit 09d94636 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Support parsing of .xz-compressed tarballs.

Implements #16424.
parent d5b32d86
# Changes in version 1.x.x - 201x-xx-xx
* Medium changes
- Parse flag thresholds in bridge network statuses, and parse the
"ignoring-advertised-bws" flag threshold in relay network status
votes.
- Parse flag thresholds in bridge network statuses, and parse the
"ignoring-advertised-bws" flag threshold in relay network status
votes.
- Support parsing of .xz-compressed tarballs using Apache Commons
Compress and XZ for Java. Applications only need to add XZ for
Java as dependency if they want to parse .xz-compressed tarballs.
# Changes in version 1.0.0 - 2015-12-05
* Major changes
- This is the initial release after four years of development. Happy
4th birthday!
- This is the initial release after four years of development.
Happy 4th birthday!
......@@ -55,6 +55,10 @@ metrics-lib currently has the following dependencies to compile:
Download, Archives, Binaries, and then the tarball or zip file for
version 1.4.1.)
- XZ for Java 1.0 (the project page at http://tukaani.org/xz/java.html
contains the most recent version, but older versions need to be
retrieved from http://mvnrepository.com/artifact/org.tukaani/xz.)
- JUnit 4.10 and Hamcrest 1.2 (go to the JUnit project page at
http://junit.org/ and select Download and install, junit.jar, version
4.10, and hamcrest-core.jar, version 1.2.)
......
......@@ -18,6 +18,7 @@
<include name="commons-compress-1.4.1.jar"/>
<include name="junit4-4.10.jar"/>
<include name="hamcrest-core-1.2.jar"/>
<include name="xz-1.0.jar"/>
</fileset>
</path>
......
......@@ -24,6 +24,7 @@ import java.util.TreeMap;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.torproject.descriptor.Descriptor;
import org.torproject.descriptor.DescriptorFile;
import org.torproject.descriptor.DescriptorParser;
......@@ -231,7 +232,8 @@ public class DescriptorReaderImpl implements DescriptorReader {
if (file.isDirectory()) {
files.addAll(Arrays.asList(file.listFiles()));
} else if (file.getName().endsWith(".tar") ||
file.getName().endsWith(".tar.bz2")) {
file.getName().endsWith(".tar.bz2") ||
file.getName().endsWith(".tar.xz")) {
this.tarballs.add(file);
} else {
String absolutePath = file.getAbsolutePath();
......@@ -268,7 +270,8 @@ public class DescriptorReaderImpl implements DescriptorReader {
while (!abortReading && !files.isEmpty()) {
File tarball = files.remove(0);
if (!tarball.getName().endsWith(".tar") &&
!tarball.getName().endsWith(".tar.bz2")) {
!tarball.getName().endsWith(".tar.bz2") &&
!tarball.getName().endsWith(".tar.xz")) {
continue;
}
String absolutePath = tarball.getAbsolutePath();
......@@ -287,6 +290,9 @@ public class DescriptorReaderImpl implements DescriptorReader {
if (tarball.getName().endsWith(".tar.bz2")) {
tais = new TarArchiveInputStream(
new BZip2CompressorInputStream(in));
} else if (tarball.getName().endsWith(".tar.xz")) {
tais = new TarArchiveInputStream(
new XZCompressorInputStream(in));
} else if (tarball.getName().endsWith(".tar")) {
tais = new TarArchiveInputStream(in);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment