fix closable resource usage

This commit is contained in:
Chloe committed 2026-02-01 16:37:59 -07:00
1 parent 0d01f8c74b
commit 2754cc4bb8
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) {