[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/master] Support parsing of .xz-compressed tarballs.
commit 09d94636ef6150871c9340f695a7c90a74ee5cb4
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Thu Dec 10 18:17:23 2015 +0100
Support parsing of .xz-compressed tarballs.
Implements #16424.
---
CHANGELOG.md | 13 ++++++++-----
CONTRIB.md | 4 ++++
build.xml | 1 +
.../torproject/descriptor/impl/DescriptorReaderImpl.java | 10 ++++++++--
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9eba21..03c2940 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,14 +1,17 @@
# 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!
diff --git a/CONTRIB.md b/CONTRIB.md
index 62c7cf8..eeb6f48 100644
--- a/CONTRIB.md
+++ b/CONTRIB.md
@@ -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.)
diff --git a/build.xml b/build.xml
index 8f1aaec..a6e0ac0 100644
--- a/build.xml
+++ b/build.xml
@@ -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>
diff --git a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index 8809d7e..e47c2a7 100644
--- a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -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);
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits