[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [metrics-db/master 2/2] Support parsing of uncompressed bridge descriptor tarballs.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue, 11 Jan 2011 09:06:09 +0100
Subject: Support parsing of uncompressed bridge descriptor tarballs.
Commit: 69d481641ffa7c664c093d27bdb73e0d2164d6c2

---
 .../torproject/ernie/db/BridgeSnapshotReader.java  |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/org/torproject/ernie/db/BridgeSnapshotReader.java b/src/org/torproject/ernie/db/BridgeSnapshotReader.java
index 1e660bd..665edbe 100644
--- a/src/org/torproject/ernie/db/BridgeSnapshotReader.java
+++ b/src/org/torproject/ernie/db/BridgeSnapshotReader.java
@@ -52,9 +52,16 @@ public class BridgeSnapshotReader {
           try {
             FileInputStream in = new FileInputStream(pop);
             if (in.available() > 0) {
-              GzipCompressorInputStream gcis =
-                  new GzipCompressorInputStream(in);
-              TarArchiveInputStream tais = new TarArchiveInputStream(gcis);
+              TarArchiveInputStream tais = null;
+              if (pop.getName().endsWith(".tar.gz")) {
+                GzipCompressorInputStream gcis =
+                    new GzipCompressorInputStream(in);
+                tais = new TarArchiveInputStream(gcis);
+              } else if (pop.getName().endsWith(".tar")) {
+                tais = new TarArchiveInputStream(in);
+              } else {
+                continue;
+              }
               BufferedInputStream bis = new BufferedInputStream(tais);
               String fn = pop.getName();
               String dateTime = fn.substring(11, 21) + " "
-- 
1.7.1