mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-29 10:00:13 +08:00
[core] Delete cache file if exception occurred while loading GroupMemberListCache. Fix #2399
This commit is contained in:
parent
62ae2ac03c
commit
eea2ef509d
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user