[tor-commits] [metrics-db/master] Keep microdescriptors in recent/ for up to 30 days.

karsten at torproject.org karsten at torproject.org
Mon Feb 15 18:55:00 UTC 2016


commit 7f0b062bcd0dee7658092784706cec7b860a1b66
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Fri Feb 12 11:06:04 2016 +0100

    Keep microdescriptors in recent/ for up to 30 days.
    
    We'll need to keep microdescriptors around longer than three days,
    because they change less frequently and are referenced much longer
    than, for example, server descriptors.
---
 src/org/torproject/ernie/db/relaydescs/ArchiveWriter.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/org/torproject/ernie/db/relaydescs/ArchiveWriter.java b/src/org/torproject/ernie/db/relaydescs/ArchiveWriter.java
index 01b4d06..a85408c 100644
--- a/src/org/torproject/ernie/db/relaydescs/ArchiveWriter.java
+++ b/src/org/torproject/ernie/db/relaydescs/ArchiveWriter.java
@@ -802,17 +802,23 @@ public class ArchiveWriter extends Thread {
   }
 
   /* Delete all files from the rsync directory that have not been modified
-   * in the last three days, and remove the .tmp extension from newly
+   * in the last three days (except for microdescriptors which are kept
+   * for up to thirty days), and remove the .tmp extension from newly
    * written files. */
   public void cleanUpRsyncDirectory() {
     long cutOffMillis = System.currentTimeMillis()
         - 3L * 24L * 60L * 60L * 1000L;
+    long cutOffMicroMillis = cutOffMillis - 27L * 24L * 60L * 60L * 1000L;
     Stack<File> allFiles = new Stack<File>();
     allFiles.add(new File("recent/relay-descriptors"));
     while (!allFiles.isEmpty()) {
       File file = allFiles.pop();
       if (file.isDirectory()) {
         allFiles.addAll(Arrays.asList(file.listFiles()));
+      } else if (file.getName().endsWith("-micro")) {
+        if (file.lastModified() < cutOffMicroMillis) {
+          file.delete();
+        }
       } else if (file.lastModified() < cutOffMillis) {
         file.delete();
       } else if (file.getName().endsWith(".tmp")) {





More information about the tor-commits mailing list