mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 14:00:12 +08:00
[api] check device info file permission before upgrade
This commit is contained in:
parent
575bac4a1e
commit
fca4a3cfb4
@ -147,8 +147,16 @@ public actual constructor(
|
||||
this.writeText(DeviceInfoManager.serialize(it, json))
|
||||
}
|
||||
}
|
||||
return DeviceInfoManager.deserialize(this.readText(), json) { upg ->
|
||||
this.writeText(DeviceInfoManager.serialize(upg, json))
|
||||
return DeviceInfoManager.deserialize(this.readText(), json) upg@{ upg ->
|
||||
if (!this.canWrite()) {
|
||||
logger.warning("Device info file $this is not writable, failed to upgrade legacy device info.")
|
||||
return@upg
|
||||
}
|
||||
try {
|
||||
this.writeText(DeviceInfoManager.serialize(upg, json))
|
||||
} catch (ex: SecurityException) {
|
||||
logger.warning("Device info file $this is not writable, failed to upgrade legacy device info.", ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user