diff options
| author | Karsten Loesing <karsten.loesing@gmx.net> | 2019-09-11 15:15:12 +0200 |
|---|---|---|
| committer | Karsten Loesing <karsten.loesing@gmx.net> | 2019-09-11 15:15:12 +0200 |
| commit | 9c1acf80a14eec1f54f456f23200a5ff70cd9c0f (patch) | |
| tree | 5965b5abc821139b19a3862e9fce95078862ff99 | |
| parent | 7a642ea1bde9640877c1af2f1a17d3b6274baf7f (diff) | |
squash! Archive bridge pool assignments again.task-31558
Replace a large number representing three days by code that actually
subtracts 3 days from a timestamp.
| -rw-r--r-- | src/main/java/org/torproject/metrics/collector/bridgepools/BridgePoolAssignmentsProcessor.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/torproject/metrics/collector/bridgepools/BridgePoolAssignmentsProcessor.java b/src/main/java/org/torproject/metrics/collector/bridgepools/BridgePoolAssignmentsProcessor.java index fae6267..0ea1949 100644 --- a/src/main/java/org/torproject/metrics/collector/bridgepools/BridgePoolAssignmentsProcessor.java +++ b/src/main/java/org/torproject/metrics/collector/bridgepools/BridgePoolAssignmentsProcessor.java @@ -26,8 +26,10 @@ import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Paths; import java.time.DateTimeException; +import java.time.Instant; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -336,8 +338,7 @@ public class BridgePoolAssignmentsProcessor extends CollecTorMain { * the last three days. */ public void cleanUpRsyncDirectory() { - long cutOffMillis = System.currentTimeMillis() - - 3L * 24L * 60L * 60L * 1000L; + Instant cutOff = Instant.now().minus(3L, ChronoUnit.DAYS); Stack<File> allFiles = new Stack<>(); allFiles.add(new File(this.recentPathName)); while (!allFiles.isEmpty()) { @@ -347,7 +348,7 @@ public class BridgePoolAssignmentsProcessor extends CollecTorMain { if (null != filesInDirectory) { allFiles.addAll(Arrays.asList(filesInDirectory)); } - } else if (file.lastModified() < cutOffMillis) { + } else if (Instant.ofEpochMilli(file.lastModified()).isBefore(cutOff)) { try { Files.deleteIfExists(file.toPath()); } catch (IOException e) { |
