aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/repo/RepoDownloadManager.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/repo/RepoDownloadManager.kt')
-rw-r--r--src/main/kotlin/repo/RepoDownloadManager.kt8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/kotlin/repo/RepoDownloadManager.kt b/src/main/kotlin/repo/RepoDownloadManager.kt
index 36ded5c..adbe36e 100644
--- a/src/main/kotlin/repo/RepoDownloadManager.kt
+++ b/src/main/kotlin/repo/RepoDownloadManager.kt
@@ -66,8 +66,12 @@ object RepoDownloadManager {
private suspend fun downloadGithubArchive(url: String): Path = withContext(IO) {
val response = HttpUtil.request(url)
val targetFile = Files.createTempFile("firmament-repo", ".zip")
- val outputChannel = Files.newOutputStream(targetFile, StandardOpenOption.CREATE, StandardOpenOption.WRITE)
- response.forInputStream().await().copyTo(outputChannel)
+ Files.newOutputStream(targetFile, StandardOpenOption.CREATE, StandardOpenOption.WRITE)
+ .use { outputStream ->
+ response.forInputStream().await().use { inputStream ->
+ inputStream.copyTo(outputStream)
+ }
+ }
targetFile
}