@@ -13,6 +13,7 @@ import java.io.FileInputStream
1313import java.net.HttpURLConnection.HTTP_NOT_FOUND
1414import java.net.HttpURLConnection.HTTP_NOT_MODIFIED
1515import java.net.HttpURLConnection.HTTP_OK
16+ import java.net.URI
1617import java.net.URL
1718import java.nio.file.Files
1819import java.nio.file.Path
@@ -48,7 +49,7 @@ class CoderDownloadService(
4849 HTTP_OK -> {
4950 context.logger.info(" Downloading binary to $localBinaryPath " )
5051 response.saveToDisk(localBinaryPath, showTextProgress, buildVersion)?.makeExecutable()
51- DownloadResult .Downloaded (localBinaryPath)
52+ DownloadResult .Downloaded (remoteBinaryURL, localBinaryPath)
5253 }
5354
5455 HTTP_NOT_MODIFIED -> {
@@ -148,10 +149,14 @@ class CoderDownloadService(
148149 }
149150
150151 suspend fun downloadSignature (showTextProgress : (String ) -> Unit ): DownloadResult {
152+ return downloadSignature(remoteBinaryURL, showTextProgress)
153+ }
154+
155+ private suspend fun downloadSignature (url : URL , showTextProgress : (String ) -> Unit ): DownloadResult {
151156 val defaultCliNameWithoutExt = context.settingsStore.defaultCliBinaryNameByOsAndArch.split(' .' ).first()
152157 val signatureName = " $defaultCliNameWithoutExt .asc"
153158
154- val signatureURL = remoteBinaryURL .withLastSegment(signatureName)
159+ val signatureURL = url .withLastSegment(signatureName)
155160 val localSignaturePath = localBinaryPath.parent.resolve(signatureName)
156161 context.logger.info(" Downloading signature from $signatureURL " )
157162
@@ -163,7 +168,7 @@ class CoderDownloadService(
163168 return when (response.code()) {
164169 HTTP_OK -> {
165170 response.saveToDisk(localSignaturePath, showTextProgress)
166- DownloadResult .Downloaded (localSignaturePath)
171+ DownloadResult .Downloaded (signatureURL, localSignaturePath)
167172 }
168173
169174 HTTP_NOT_FOUND -> {
@@ -180,5 +185,10 @@ class CoderDownloadService(
180185 )
181186 }
182187 }
188+
189+ }
190+
191+ suspend fun downloadReleasesSignature (showTextProgress : (String ) -> Unit ): DownloadResult {
192+ return downloadSignature(URI .create(" https://releases.coder.com/bin" ).toURL(), showTextProgress)
183193 }
184194}
0 commit comments