@@ -21,6 +21,8 @@ export enum ProgressReportStage {
21
21
Downloading = 'downloading' ,
22
22
/** Fired when the command is issued to do a synchronous extraction. May not fire depending on the platform and options. */
23
23
ExtractingSynchonrously = 'extractingSynchonrously' ,
24
+ /** Fired when the download fails and a retry will be attempted */
25
+ Retrying = 'retrying' ,
24
26
/** Fired after folder is downloaded and unzipped */
25
27
NewInstallComplete = 'newInstallComplete' ,
26
28
}
@@ -33,6 +35,7 @@ export type ProgressReport =
33
35
| { stage : ProgressReportStage . FoundMatchingInstall ; downloadedPath : string }
34
36
| { stage : ProgressReportStage . ResolvingCDNLocation ; url : string }
35
37
| { stage : ProgressReportStage . Downloading ; url : string ; totalBytes : number ; bytesSoFar : number ; }
38
+ | { stage : ProgressReportStage . Retrying ; error : Error , attempt : number ; totalAttempts : number }
36
39
| { stage : ProgressReportStage . ExtractingSynchonrously ; }
37
40
| { stage : ProgressReportStage . NewInstallComplete , downloadedPath : string ; }
38
41
@@ -76,9 +79,6 @@ export class ConsoleReporter implements ProgressReporter {
76
79
case ProgressReportStage . FoundMatchingInstall :
77
80
console . log ( `Found existing install in ${ report . downloadedPath } . Skipping download` ) ;
78
81
break ;
79
- case ProgressReportStage . NewInstallComplete :
80
- console . log ( `Downloaded VS Code ${ this . version } into ${ report . downloadedPath } ` ) ;
81
- break ;
82
82
case ProgressReportStage . ResolvingCDNLocation :
83
83
console . log ( `Downloading VS Code ${ this . version } from ${ report . url } ` )
84
84
break ;
@@ -91,13 +91,12 @@ export class ConsoleReporter implements ProgressReporter {
91
91
this . downloadReport . report = report ;
92
92
}
93
93
break ;
94
+ case ProgressReportStage . Retrying :
95
+ this . flushDownloadReport ( ) ;
96
+ console . log ( `Error downloading, retrying (attempt ${ report . attempt } of ${ report . totalAttempts } ): ${ report . error . message } ` ) ;
97
+ break ;
94
98
case ProgressReportStage . NewInstallComplete :
95
- if ( this . downloadReport ) {
96
- clearTimeout ( this . downloadReport . timeout ) ;
97
- }
98
- if ( this . showDownloadProgress ) {
99
- console . log ( '' ) ;
100
- }
99
+ this . flushDownloadReport ( ) ;
101
100
console . log ( `Downloaded VS Code into ${ report . downloadedPath } ` ) ;
102
101
break ;
103
102
}
@@ -107,6 +106,13 @@ export class ConsoleReporter implements ProgressReporter {
107
106
console . error ( err ) ;
108
107
}
109
108
109
+ private flushDownloadReport ( ) {
110
+ if ( this . showDownloadProgress ) {
111
+ this . reportDownload ( ) ;
112
+ console . log ( '' ) ;
113
+ }
114
+ }
115
+
110
116
private reportDownload ( ) {
111
117
if ( ! this . downloadReport ) {
112
118
return ;
0 commit comments