[tor-commits] [metrics-db/master] Exclude bridge network statuses from duplicates check

karsten at torproject.org karsten at torproject.org
Tue Feb 22 14:18:41 UTC 2011


commit b982a538824667313f6a31319c2ed3ee4df7e741
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Feb 22 15:16:17 2011 +0100

    Exclude bridge network statuses from duplicates check
    
    There's simply no way for us to detect whether two (subsequent) statuses
    are legitimately equal or not, so we'll have to consider them valid.  The
    only thing we can do is warn if referenced descriptors are older than a
    given number of hours and ask the operator to investigate manually.  (This
    check will be contained in a separate commit.)
---
 .../torproject/ernie/db/BridgeSnapshotReader.java  |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/org/torproject/ernie/db/BridgeSnapshotReader.java b/src/org/torproject/ernie/db/BridgeSnapshotReader.java
index 13ab58d..310029a 100644
--- a/src/org/torproject/ernie/db/BridgeSnapshotReader.java
+++ b/src/org/torproject/ernie/db/BridgeSnapshotReader.java
@@ -94,13 +94,6 @@ public class BridgeSnapshotReader {
                 }
                 String fileDigest = Hex.encodeHexString(DigestUtils.sha(
                     allData));
-                if (!descriptorImportHistory.contains(fileDigest)) {
-                  descriptorImportHistory.add(fileDigest);
-                  parsedFiles++;
-                } else {
-                  skippedFiles++;
-                  continue;
-                }
                 String ascii = new String(allData, "US-ASCII");
                 BufferedReader br3 = new BufferedReader(new StringReader(
                     ascii));
@@ -115,6 +108,11 @@ public class BridgeSnapshotReader {
                 if (firstLine.startsWith("r ")) {
                   bdp.parse(allData, dateTime, false);
                   parsedStatuses++;
+                } else if (descriptorImportHistory.contains(fileDigest)) {
+                  /* Skip server descriptors or extra-info descriptors if
+                   * we parsed them before. */
+                  skippedFiles++;
+                  continue;
                 } else {
                   int start = -1, sig = -1, end = -1;
                   String startToken =
@@ -160,6 +158,8 @@ public class BridgeSnapshotReader {
                     }
                   }
                 }
+                descriptorImportHistory.add(fileDigest);
+                parsedFiles++;
               }
             }
             in.close();



More information about the tor-commits mailing list