[tor-commits] [metrics-db/master] Parse "published" lines from bridge statuses.

karsten at torproject.org karsten at torproject.org
Mon Oct 13 11:58:37 UTC 2014


commit 45d680c6241e161a532ef255089d113da45b54f4
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Mon Oct 13 13:56:50 2014 +0200

    Parse "published" lines from bridge statuses.
    
    Related to #12951 that adds this line.  Before that change, we'd simply
    use the file's last-modified time as publication time and write that to
    the sanitized status file.
---
 .../ernie/db/bridgedescs/BridgeSnapshotReader.java           |    5 +++--
 .../ernie/db/bridgedescs/SanitizedBridgesWriter.java         |   10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java b/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
index 493a7b6..3433cfe 100644
--- a/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
+++ b/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
@@ -118,8 +118,9 @@ public class BridgeSnapshotReader {
                     break;
                   }
                 }
-                if (firstLine.startsWith("r ") ||
-                    firstLine.startsWith("flag-thresholds ")) {
+                if (firstLine.startsWith("published ") ||
+                    firstLine.startsWith("flag-thresholds ") ||
+                    firstLine.startsWith("r ")) {
                   bdp.parse(allData, dateTime);
                   parsedStatuses++;
                 } else if (descriptorImportHistory.contains(fileDigest)) {
diff --git a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
index 72cb65e..a1bb259 100644
--- a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
@@ -444,8 +444,14 @@ public class SanitizedBridgesWriter extends Thread {
       String hashedBridgeIdentityHex = null;
       while ((line = br.readLine()) != null) {
 
-        /* Header lines don't have to be cleaned up. */
-        if (line.startsWith("flag-thresholds ")) {
+        /* Use publication time from "published" line instead of the
+         * file's last-modified time.  Don't copy over the line, because
+         * we're going to write a "published" line below. */
+        if (line.startsWith("published ")) {
+          publicationTime = line.substring("published ".length());
+
+        /* Additional header lines don't have to be cleaned up. */
+        } else if (line.startsWith("flag-thresholds ")) {
           header.append(line + "\n");
 
         /* r lines contain sensitive information that needs to be removed



More information about the tor-commits mailing list