TunnelManager: Clear primary tunnel when it's removed

Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
Samuel Holland 2018-01-01 02:15:34 -06:00
parent 609194fae2
commit 58eedfd6d9

View File

@ -70,7 +70,11 @@ public final class TunnelManager {
Log.v(TAG, "Requested delete tunnel " + tunnel.getName() + " state=" + tunnel.getState());
return backend.setState(tunnel, State.DOWN)
.thenCompose(x -> configStore.delete(tunnel.getName()))
.thenAccept(x -> tunnels.remove(tunnel.getName()));
.thenAccept(x -> {
tunnels.remove(tunnel.getName());
if (tunnel.getName().equals(preferences.getString(KEY_PRIMARY_TUNNEL, null)))
preferences.edit().remove(KEY_PRIMARY_TUNNEL).apply();
});
}
public TunnelCollection getTunnels() {