1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-09 02:10:10 +08:00

Fix fileBasedDeviceInfo on native: exception when file does not exist

This commit is contained in:
Him188 2022-06-04 15:02:09 +01:00
parent 6daef11399
commit 48e8268461
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375

View File

@ -329,6 +329,9 @@ public actual open class BotConfiguration { // open for Java
public actual fun fileBasedDeviceInfo(filepath: String) {
deviceInfo = {
val file = MiraiFile.create(workingDir).resolve(filepath)
if (!file.exists()) {
file.writeText(DeviceInfoManager.serialize(DeviceInfo.random(), json))
}
DeviceInfoManager.deserialize(file.readText(), json)
}
}