Guard synchronizedList's iteration

It's needed to guard a synchronizedList when iterating it
This commit is contained in:
LoveSy 2022-01-27 08:10:22 +08:00 committed by John Wu
parent 18de60f68c
commit 5a88984d34

View File

@ -103,9 +103,11 @@ class FlashViewModel : BaseViewModel() {
val name = "magisk_install_log_%s.log".format(now.toTime(timeFormatStandard))
val file = MediaStoreUtils.getFile(name, true)
file.uri.outputStream().bufferedWriter().use { writer ->
logItems.forEach {
writer.write(it)
writer.newLine()
synchronized(logItems) {
logItems.forEach {
writer.write(it)
writer.newLine()
}
}
}
SnackbarEvent(file.toString()).publish()