diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/kotlin/repo/RepoDownloadManager.kt | 8 | ||||
| -rw-r--r-- | src/main/kotlin/util/net/HttpUtil.kt | 1 |
2 files changed, 7 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 } diff --git a/src/main/kotlin/util/net/HttpUtil.kt b/src/main/kotlin/util/net/HttpUtil.kt index 50e0644..1b810e3 100644 --- a/src/main/kotlin/util/net/HttpUtil.kt +++ b/src/main/kotlin/util/net/HttpUtil.kt @@ -17,6 +17,7 @@ import moe.nea.firmament.Firmament object HttpUtil { val httpClient = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.NORMAL) .build() data class Request(val request: HttpRequest.Builder) { |
