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:
parent
6daef11399
commit
48e8268461
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user