Close streams

This commit is contained in:
topjohnwu 2020-08-22 20:33:50 -07:00
parent a22a1dd284
commit 0e5a32b476

View File

@ -344,7 +344,9 @@ abstract class MagiskInstallImpl : KoinComponent {
private suspend fun postOTA(): Boolean {
val bootctl = SuFile("/data/adb/bootctl")
try {
service.fetchBootctl().byteStream().copyTo(SuFileOutputStream(bootctl))
withStreams(service.fetchBootctl().byteStream(), SuFileOutputStream(bootctl)) {
it, out -> it.copyTo(out)
}
} catch (e: IOException) {
console.add("! Unable to download bootctl")
Timber.e(e)