Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 缓存可能因为计算机硬碟或程式不稳定造成损毁。 #2841

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions mirai-core-utils/src/commonMain/kotlin/Serialization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public fun <T> MiraiFile.loadNotBlankAs(
if (!this.exists() || this.length == 0L) {
return null
}
return stringFormat.decodeFromString(serializer, this.readText())
return try{
stringFormat.decodeFromString(serializer, this.readText())
}catch(e:Throwable){//broken file
e.printStackTrace()
null
}
Him188 marked this conversation as resolved.
Show resolved Hide resolved
}

public fun <T> MiraiFile.loadNotBlankAs(
Expand All @@ -82,6 +87,10 @@ public fun <T> MiraiFile.loadNotBlankAs(
if (!this.exists() || this.length == 0L) {
return null
}
return binaryFormat.decodeFromByteArray(serializer, this.readBytes())
return try{
binaryFormat.decodeFromByteArray(serializer, this.readBytes())
}catch(e:Throwable){//broken file
e.printStackTrace()
null
}
Him188 marked this conversation as resolved.
Show resolved Hide resolved
}

Loading