summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-06 05:09:53 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-06 05:20:11 -0600
commit2315a699fb21fe9e49be7844980dde832c420508 (patch)
tree023c70206fed931193ff3a106945ddb514556ff6 /app/src/main
parentdf7d18fb5d332a2aa341e97274dc6e53cc4ffe11 (diff)
TunnelManager: Enumerate running tunnels only once
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/android/model/TunnelManager.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
index eaf8c0d6..3682cfcd 100644
--- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java
+++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
@@ -87,13 +87,11 @@ public final class TunnelManager {
public void onCreate() {
Log.v(TAG, "onCreate triggered");
- configStore.enumerate()
- .thenApply(names -> StreamSupport.stream(names)
- .map(this::add)
- .map(Tunnel::getStateAsync)
- .toArray(CompletableFuture[]::new))
- .thenCompose(CompletableFuture::allOf)
- .whenComplete(ExceptionLoggers.E);
+ configStore.enumerate().thenAcceptBoth(backend.enumerate(), (names, running) -> {
+ for (final String name : names) {
+ add(name, null, running.contains(name) ? State.UP : State.DOWN);
+ }
+ }).whenComplete(ExceptionLoggers.D);
}
public CompletionStage<Void> restoreState() {