mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 18:54:43 +08:00
[core] Delete cache file if exception occurred while loading GroupMemberListCache. Fix #2399
This commit is contained in:
parent
62ae2ac03c
commit
eea2ef509d
@ -114,10 +114,18 @@ internal class GroupMemberListCaches(
|
|||||||
return map.getOrPut(id) {
|
return map.getOrPut(id) {
|
||||||
val file = resolveCacheFile(id)
|
val file = resolveCacheFile(id)
|
||||||
if (file.exists() && file.isFile) {
|
if (file.exists() && file.isFile) {
|
||||||
|
try {
|
||||||
val text = file.readText()
|
val text = file.readText()
|
||||||
if (text.isNotBlank()) {
|
if (text.isNotBlank()) {
|
||||||
return JsonForCache.decodeFromString(GroupMemberListCache.serializer(), text)
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupMemberListCache(0, emptyList())
|
GroupMemberListCache(0, emptyList())
|
||||||
|
Loading…
Reference in New Issue
Block a user