@@ -129,28 +129,26 @@ export class Storage {
129
129
const enableDownloads =
130
130
vscode . workspace . getConfiguration ( ) . get ( "coder.enableDownloads" ) !==
131
131
false ;
132
- this . output . info (
133
- `Downloads are ${ enableDownloads ? "enabled" : "disabled" } ` ,
134
- ) ;
132
+ this . output . info ( "Downloads are" , enableDownloads ? "enabled" : "disabled" ) ;
135
133
136
134
// Get the build info to compare with the existing binary version, if any,
137
135
// and to log for debugging.
138
136
const buildInfo = await restClient . getBuildInfo ( ) ;
139
- this . output . info ( ` Got server version: ${ buildInfo . version } ` ) ;
137
+ this . output . info ( " Got server version" , buildInfo . version ) ;
140
138
141
139
// Check if there is an existing binary and whether it looks valid. If it
142
140
// is valid and matches the server, or if it does not match the server but
143
141
// downloads are disabled, we can return early.
144
142
const binPath = path . join ( this . getBinaryCachePath ( label ) , cli . name ( ) ) ;
145
- this . output . info ( ` Using binary path: ${ binPath } ` ) ;
143
+ this . output . info ( " Using binary path" , binPath ) ;
146
144
const stat = await cli . stat ( binPath ) ;
147
145
if ( stat === undefined ) {
148
146
this . output . info ( "No existing binary found, starting download" ) ;
149
147
} else {
150
- this . output . info ( ` Existing binary size is ${ prettyBytes ( stat . size ) } ` ) ;
148
+ this . output . info ( " Existing binary size is" , prettyBytes ( stat . size ) ) ;
151
149
try {
152
150
const version = await cli . version ( binPath ) ;
153
- this . output . info ( ` Existing binary version is ${ version } ` ) ;
151
+ this . output . info ( " Existing binary version is" , version ) ;
154
152
// If we have the right version we can avoid the request entirely.
155
153
if ( version === buildInfo . version ) {
156
154
this . output . info (
@@ -167,26 +165,24 @@ export class Storage {
167
165
"Downloading since existing binary does not match the server version" ,
168
166
) ;
169
167
} catch ( error ) {
170
- this . output . error (
168
+ this . output . warn (
171
169
`Unable to get version of existing binary: ${ error } . Downloading new binary instead` ,
172
170
) ;
173
171
}
174
172
}
175
173
176
174
if ( ! enableDownloads ) {
177
- this . output . error (
178
- "Unable to download CLI because downloads are disabled" ,
179
- ) ;
175
+ this . output . warn ( "Unable to download CLI because downloads are disabled" ) ;
180
176
throw new Error ( "Unable to download CLI because downloads are disabled" ) ;
181
177
}
182
178
183
179
// Remove any left-over old or temporary binaries.
184
180
const removed = await cli . rmOld ( binPath ) ;
185
181
removed . forEach ( ( { fileName, error } ) => {
186
182
if ( error ) {
187
- this . output . error ( `Failed to remove ${ fileName } : ${ error } ` ) ;
183
+ this . output . warn ( `Failed to remove ${ fileName } ` , error ) ;
188
184
} else {
189
- this . output . info ( ` Removed ${ fileName } ` ) ;
185
+ this . output . info ( " Removed" , fileName ) ;
190
186
}
191
187
} ) ;
192
188
@@ -199,12 +195,12 @@ export class Storage {
199
195
configSource && String ( configSource ) . trim ( ) . length > 0
200
196
? String ( configSource )
201
197
: "/bin/" + binName ;
202
- this . output . info ( ` Downloading binary from: ${ binSource } ` ) ;
198
+ this . output . info ( " Downloading binary from" , binSource ) ;
203
199
204
200
// Ideally we already caught that this was the right version and returned
205
201
// early, but just in case set the ETag.
206
202
const etag = stat !== undefined ? await cli . eTag ( binPath ) : "" ;
207
- this . output . info ( ` Using ETag: ${ etag } ` ) ;
203
+ this . output . info ( " Using ETag" , etag ) ;
208
204
209
205
// Make the download request.
210
206
const controller = new AbortController ( ) ;
@@ -220,18 +216,19 @@ export class Storage {
220
216
// Ignore all errors so we can catch a 404!
221
217
validateStatus : ( ) => true ,
222
218
} ) ;
223
- this . output . info ( ` Got status code ${ resp . status } ` ) ;
219
+ this . output . info ( " Got status code" , resp . status ) ;
224
220
225
221
switch ( resp . status ) {
226
222
case 200 : {
227
223
const rawContentLength = resp . headers [ "content-length" ] ;
228
224
const contentLength = Number . parseInt ( rawContentLength ) ;
229
225
if ( Number . isNaN ( contentLength ) ) {
230
- this . output . error (
231
- `Got invalid or missing content length: ${ rawContentLength } ` ,
226
+ this . output . warn (
227
+ "Got invalid or missing content length" ,
228
+ rawContentLength ,
232
229
) ;
233
230
} else {
234
- this . output . info ( ` Got content length: ${ prettyBytes ( contentLength ) } ` ) ;
231
+ this . output . info ( " Got content length" , prettyBytes ( contentLength ) ) ;
235
232
}
236
233
237
234
// Download to a temporary file.
@@ -312,7 +309,7 @@ export class Storage {
312
309
// False means the user canceled, although in practice it appears we
313
310
// would not get this far because VS Code already throws on cancelation.
314
311
if ( ! completed ) {
315
- this . output . error ( "User aborted download" ) ;
312
+ this . output . warn ( "User aborted download" ) ;
316
313
throw new Error ( "User aborted download" ) ;
317
314
}
318
315
@@ -327,25 +324,27 @@ export class Storage {
327
324
const oldBinPath =
328
325
binPath + ".old-" + Math . random ( ) . toString ( 36 ) . substring ( 8 ) ;
329
326
this . output . info (
330
- `Moving existing binary to ${ path . basename ( oldBinPath ) } ` ,
327
+ "Moving existing binary to" ,
328
+ path . basename ( oldBinPath ) ,
331
329
) ;
332
330
await fs . rename ( binPath , oldBinPath ) ;
333
331
}
334
332
335
333
// Then move the temporary binary into the right place.
336
- this . output . info ( ` Moving downloaded file to ${ path . basename ( binPath ) } ` ) ;
334
+ this . output . info ( " Moving downloaded file to" , path . basename ( binPath ) ) ;
337
335
await fs . mkdir ( path . dirname ( binPath ) , { recursive : true } ) ;
338
336
await fs . rename ( tempFile , binPath ) ;
339
337
340
338
// For debugging, to see if the binary only partially downloaded.
341
339
const newStat = await cli . stat ( binPath ) ;
342
340
this . output . info (
343
- `Downloaded binary size is ${ prettyBytes ( newStat ?. size || 0 ) } ` ,
341
+ "Downloaded binary size is" ,
342
+ prettyBytes ( newStat ?. size || 0 ) ,
344
343
) ;
345
344
346
345
// Make sure we can execute this new binary.
347
346
const version = await cli . version ( binPath ) ;
348
- this . output . info ( ` Downloaded binary version is ${ version } ` ) ;
347
+ this . output . info ( " Downloaded binary version is" , version ) ;
349
348
350
349
return binPath ;
351
350
}
0 commit comments