1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-05-06 06:12:34 +08:00

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

This commit is contained in:
赵怡然 2024-02-27 23:58:28 +08:00 committed by GitHub
parent eeb32177f6
commit 5bb86cf84f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}
}
public fun <T> MiraiFile.loadNotBlankAs(
@ -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
}
}