[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-db/master] Avoid duplicates when storing bridge descriptors.
commit 91aeeb6f4e7bd893fa2ded40e13138ab7f9ee3cc
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue May 5 12:22:58 2015 +0200
Avoid duplicates when storing bridge descriptors.
Implements #12676.
---
.../ernie/db/bridgedescs/SanitizedBridgesWriter.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
index 1c64d79..37f37a1 100644
--- a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
@@ -852,6 +852,11 @@ public class SanitizedBridgesWriter extends Thread {
for (int i = 0; i < outputFiles.length; i++) {
File outputFile = outputFiles[i];
boolean appendToFile = append[i];
+ if (outputFile.exists() && !appendToFile) {
+ /* We already stored this descriptor to disk before, so let's
+ * not store it yet another time. */
+ break;
+ }
outputFile.getParentFile().mkdirs();
BufferedWriter bw = new BufferedWriter(new FileWriter(
outputFile, appendToFile));
@@ -999,6 +1004,11 @@ public class SanitizedBridgesWriter extends Thread {
for (int i = 0; i < outputFiles.length; i++) {
File outputFile = outputFiles[i];
boolean appendToFile = append[i];
+ if (outputFile.exists() && !appendToFile) {
+ /* We already stored this descriptor to disk before, so let's
+ * not store it yet another time. */
+ break;
+ }
outputFile.getParentFile().mkdirs();
BufferedWriter bw = new BufferedWriter(new FileWriter(
outputFile, appendToFile));
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits