forked from geode-sdk/android-launcher
fix closable resource usage
This commit is contained in:
2 files changed
+8
-6
No files matched your search
@@ -147,14 +147,16 @@ class ReleaseManager private constructor(
|
||||
_uiState.value = ReleaseManagerState.InDownload(0, download.size)
|
||||
|
||||
try {
|
||||
val fileStream = DownloadUtils.downloadStream(
|
||||
DownloadUtils.downloadStream(
|
||||
httpClient,
|
||||
download.url
|
||||
) { progress, outOf ->
|
||||
_uiState.value = ReleaseManagerState.InDownload(progress, outOf)
|
||||
}.use { fileStream ->
|
||||
outputFile.outputStream().use {
|
||||
fileStream.copyTo(it)
|
||||
}
|
||||
}
|
||||
|
||||
fileStream.copyTo(outputFile.outputStream())
|
||||
} catch (e: Exception) {
|
||||
sendError(e)
|
||||
return
|
||||
|
||||
@@ -58,9 +58,9 @@ object DownloadUtils {
|
||||
val progressClient = progressClientBuilder.build()
|
||||
|
||||
val call = progressClient.newCall(request)
|
||||
return call.executeAsync().use { response ->
|
||||
response.body.byteStream()
|
||||
}
|
||||
val response = call.executeAsync()
|
||||
|
||||
return response.body.byteStream()
|
||||
}
|
||||
|
||||
suspend fun extractFileFromZipStream(inputStream: InputStream, outputStream: OutputStream, zipPath: String) {
|
||||
|
||||
Reference in new issue
Block a user