diff --git a/mirai-core/src/commonMain/kotlin/network/ContactListCache.kt b/mirai-core/src/commonMain/kotlin/network/ContactListCache.kt index 266a74063..8698bab46 100644 --- a/mirai-core/src/commonMain/kotlin/network/ContactListCache.kt +++ b/mirai-core/src/commonMain/kotlin/network/ContactListCache.kt @@ -114,9 +114,17 @@ internal class GroupMemberListCaches( return map.getOrPut(id) { val file = resolveCacheFile(id) if (file.exists() && file.isFile) { - val text = file.readText() - if (text.isNotBlank()) { - return JsonForCache.decodeFromString(GroupMemberListCache.serializer(), text) + try { + val text = file.readText() + if (text.isNotBlank()) { + return JsonForCache.decodeFromString(GroupMemberListCache.serializer(), text) + } + } catch (e: Exception) { + logger.warning( + "Exception while loading GroupMemberListCache for group $id, possibly file corrupted. Deleting cache file.", + e + ) + file.delete() } }