From 4e9e2476f1e58ed1a336b7531ff78a04e3bd7bfa Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sun, 25 Jul 2021 18:56:29 +0200 Subject: [PATCH] server: fix crash when favicon is not available --- .../java/de/bixilon/minosoft/config/server/Server.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/config/server/Server.kt b/src/main/java/de/bixilon/minosoft/config/server/Server.kt index 43ff291e2..5df23ea7e 100644 --- a/src/main/java/de/bixilon/minosoft/config/server/Server.kt +++ b/src/main/java/de/bixilon/minosoft/config/server/Server.kt @@ -38,7 +38,10 @@ data class Server( return } field = value - faviconHash?.let { AssetsUtil.deleteAsset(it, true) } + faviconHash?.let { + // ToDo: Check if other server is using favicon + AssetsUtil.deleteAsset(it, true) + } if (value == null) { faviconHash = null return @@ -60,7 +63,12 @@ data class Server( if (id > nextServerId) { nextServerId = id + 1 } - faviconHash?.let { favicon = AssetsUtil.readAsset(it, true) } + try { + faviconHash?.let { favicon = AssetsUtil.readAsset(it, true) } + } catch (exception: Exception) { + exception.printStackTrace() + faviconHash = null + } }