Prevent race condition while reading uuid
This commit is contained in:
@@ -146,7 +146,9 @@ class RootServer {
|
|||||||
try {
|
try {
|
||||||
val token2 = UUID.randomUUID().toString()
|
val token2 = UUID.randomUUID().toString()
|
||||||
val persistence = File(context.codeCacheDir, ".librootkotlinx-uuid")
|
val persistence = File(context.codeCacheDir, ".librootkotlinx-uuid")
|
||||||
val uuid = context.packageName + '@' + if (persistence.canRead()) persistence.readText() else {
|
val uuid = context.packageName + '@' + try {
|
||||||
|
persistence.readText()
|
||||||
|
} catch (_: FileNotFoundException) {
|
||||||
UUID.randomUUID().toString().also { persistence.writeText(it) }
|
UUID.randomUUID().toString().also { persistence.writeText(it) }
|
||||||
}
|
}
|
||||||
val (script, relocated) = AppProcess.relocateScript(uuid)
|
val (script, relocated) = AppProcess.relocateScript(uuid)
|
||||||
|
|||||||
Reference in New Issue
Block a user