From 6799deea9dbd054edd0fd8eec30ad399c0fb6ca9 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 15 Jul 2016 20:45:29 +0200 Subject: [PATCH] Fixed crash when picking relays if a neighbor wasn't in the db. --- .../main/scala/com/nutomic/ensichat/core/util/Database.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/com/nutomic/ensichat/core/util/Database.scala b/core/src/main/scala/com/nutomic/ensichat/core/util/Database.scala index 8cd4a3f..3fa054c 100644 --- a/core/src/main/scala/com/nutomic/ensichat/core/util/Database.scala +++ b/core/src/main/scala/com/nutomic/ensichat/core/util/Database.scala @@ -171,7 +171,10 @@ class Database(path: File, settings: SettingsInterface, callbackInterface: Callb val map = Await.result(db.run(knownDevices.result), Duration.Inf).toMap connections .toList - .sortBy(map(_).getMillis) + .sortBy { c => + val duration = map.get(c) + duration.map(_.getMillis).getOrElse(0L) + } .reverse }