@@ -13,6 +13,7 @@ import java.io.FileInputStream
13
13
import java.net.HttpURLConnection.HTTP_NOT_FOUND
14
14
import java.net.HttpURLConnection.HTTP_NOT_MODIFIED
15
15
import java.net.HttpURLConnection.HTTP_OK
16
+ import java.net.URI
16
17
import java.net.URL
17
18
import java.nio.file.Files
18
19
import java.nio.file.Path
@@ -48,7 +49,7 @@ class CoderDownloadService(
48
49
HTTP_OK -> {
49
50
context.logger.info(" Downloading binary to $localBinaryPath " )
50
51
response.saveToDisk(localBinaryPath, showTextProgress, buildVersion)?.makeExecutable()
51
- DownloadResult .Downloaded (localBinaryPath)
52
+ DownloadResult .Downloaded (remoteBinaryURL, localBinaryPath)
52
53
}
53
54
54
55
HTTP_NOT_MODIFIED -> {
@@ -148,10 +149,14 @@ class CoderDownloadService(
148
149
}
149
150
150
151
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 {
151
156
val defaultCliNameWithoutExt = context.settingsStore.defaultCliBinaryNameByOsAndArch.split(' .' ).first()
152
157
val signatureName = " $defaultCliNameWithoutExt .asc"
153
158
154
- val signatureURL = remoteBinaryURL .withLastSegment(signatureName)
159
+ val signatureURL = url .withLastSegment(signatureName)
155
160
val localSignaturePath = localBinaryPath.parent.resolve(signatureName)
156
161
context.logger.info(" Downloading signature from $signatureURL " )
157
162
@@ -163,7 +168,7 @@ class CoderDownloadService(
163
168
return when (response.code()) {
164
169
HTTP_OK -> {
165
170
response.saveToDisk(localSignaturePath, showTextProgress)
166
- DownloadResult .Downloaded (localSignaturePath)
171
+ DownloadResult .Downloaded (signatureURL, localSignaturePath)
167
172
}
168
173
169
174
HTTP_NOT_FOUND -> {
@@ -180,5 +185,10 @@ class CoderDownloadService(
180
185
)
181
186
}
182
187
}
188
+
189
+ }
190
+
191
+ suspend fun downloadReleasesSignature (showTextProgress : (String ) -> Unit ): DownloadResult {
192
+ return downloadSignature(URI .create(" https://releases.coder.com/bin" ).toURL(), showTextProgress)
183
193
}
184
194
}
0 commit comments