@@ -53,6 +53,8 @@ export class MonitorService extends CoreClientAware implements Disposable {
53
53
protected readonly webSocketProvider : WebSocketProvider =
54
54
new WebSocketProviderImpl ( ) ;
55
55
56
+ protected uploadInProgress = false ;
57
+
56
58
constructor (
57
59
@inject ( ILogger )
58
60
@named ( MonitorServiceName )
@@ -80,6 +82,10 @@ export class MonitorService extends CoreClientAware implements Disposable {
80
82
) ;
81
83
}
82
84
85
+ setUploadInProgress ( status : boolean ) : void {
86
+ this . uploadInProgress = status ;
87
+ }
88
+
83
89
getWebsocketAddressPort ( ) : number {
84
90
return this . webSocketProvider . getAddress ( ) . port ;
85
91
}
@@ -113,11 +119,14 @@ export class MonitorService extends CoreClientAware implements Disposable {
113
119
return Status . CONFIG_MISSING ;
114
120
}
115
121
122
+ if ( this . uploadInProgress ) {
123
+ return Status . UPLOAD_IN_PROGRESS ;
124
+ }
125
+
116
126
this . logger . info ( 'starting monitor' ) ;
117
127
await this . coreClientProvider . initialized ;
118
128
const coreClient = await this . coreClient ( ) ;
119
129
const { client, instance } = coreClient ;
120
-
121
130
this . duplex = client . monitor ( ) ;
122
131
this . duplex
123
132
. on ( 'close' , ( ) => {
@@ -205,7 +214,7 @@ export class MonitorService extends CoreClientAware implements Disposable {
205
214
* Pauses the currently running monitor, it still closes the gRPC connection
206
215
* with the underlying monitor process but it doesn't stop the message handlers
207
216
* currently running.
208
- * This is mainly used to handle upload when to the board/port combination
217
+ * This is mainly used to handle upload with the board/port combination
209
218
* the monitor is listening to.
210
219
* @returns
211
220
*/
@@ -223,7 +232,8 @@ export class MonitorService extends CoreClientAware implements Disposable {
223
232
this . logger . info (
224
233
`stopped monitor to ${ this . port ?. address } using ${ this . port ?. protocol } `
225
234
) ;
226
- resolve ( ) ;
235
+
236
+ this . duplex . on ( 'end' , resolve ) ;
227
237
} ) ;
228
238
}
229
239
0 commit comments