@@ -34,7 +34,6 @@ import { nls } from '@theia/core/lib/common';
34
34
import { ApplicationConnectionStatusContribution } from '../../theia/core/connection-status-service' ;
35
35
import { ExecuteWithProgress } from '../../../common/protocol/progressible' ;
36
36
import {
37
- synchronizingSketchbook ,
38
37
pullingSketch ,
39
38
pushingSketch ,
40
39
} from '../../contributions/cloud-contribution' ;
@@ -101,7 +100,7 @@ export class CloudSketchbookTree extends SketchbookTree {
101
100
}
102
101
103
102
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
104
- async pull ( arg : any ) : Promise < void > {
103
+ async pull ( arg : any , noProgress = false ) : Promise < void > {
105
104
const {
106
105
// model,
107
106
node,
@@ -135,32 +134,40 @@ export class CloudSketchbookTree extends SketchbookTree {
135
134
return ;
136
135
}
137
136
}
138
- return this . runWithState ( node , 'pulling' , async ( node ) => {
139
- const commandsCopy = node . commands ;
140
- node . commands = [ ] ;
137
+ return this . runWithState (
138
+ node ,
139
+ 'pulling' ,
140
+ async ( node ) => {
141
+ const commandsCopy = node . commands ;
142
+ node . commands = [ ] ;
141
143
142
- const localUri = await this . fileService . toUnderlyingResource (
143
- LocalCacheUri . root . resolve ( node . remoteUri . path )
144
- ) ;
145
- await this . sync ( node . remoteUri , localUri ) ;
144
+ const localUri = await this . fileService . toUnderlyingResource (
145
+ LocalCacheUri . root . resolve ( node . remoteUri . path )
146
+ ) ;
147
+ await this . sync ( node . remoteUri , localUri ) ;
146
148
147
- this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
149
+ this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
148
150
149
- node . commands = commandsCopy ;
150
- this . messageService . info (
151
- nls . localize (
152
- 'arduino/cloud/donePulling' ,
153
- "Done pulling '{0}'." ,
154
- node . fileStat . name
155
- ) ,
156
- {
157
- timeout : MESSAGE_TIMEOUT ,
158
- }
159
- ) ;
160
- } ) ;
151
+ node . commands = commandsCopy ;
152
+ this . messageService . info (
153
+ nls . localize (
154
+ 'arduino/cloud/donePulling' ,
155
+ "Done pulling '{0}'." ,
156
+ node . fileStat . name
157
+ ) ,
158
+ {
159
+ timeout : MESSAGE_TIMEOUT ,
160
+ }
161
+ ) ;
162
+ } ,
163
+ noProgress
164
+ ) ;
161
165
}
162
166
163
- async push ( node : CloudSketchbookTree . CloudSketchDirNode ) : Promise < void > {
167
+ async push (
168
+ node : CloudSketchbookTree . CloudSketchDirNode ,
169
+ noProgress = false
170
+ ) : Promise < void > {
164
171
if ( ! CloudSketchbookTree . CloudSketchTreeNode . isSynced ( node ) ) {
165
172
throw new Error (
166
173
nls . localize (
@@ -195,37 +202,42 @@ export class CloudSketchbookTree extends SketchbookTree {
195
202
return ;
196
203
}
197
204
}
198
- return this . runWithState ( node , 'pushing' , async ( node ) => {
199
- if ( ! CloudSketchbookTree . CloudSketchTreeNode . isSynced ( node ) ) {
200
- throw new Error (
201
- nls . localize (
202
- 'arduino/cloud/pullFirst' ,
203
- 'You have to pull first to be able to push to the Cloud.'
204
- )
205
- ) ;
206
- }
207
- const commandsCopy = node . commands ;
208
- node . commands = [ ] ;
205
+ return this . runWithState (
206
+ node ,
207
+ 'pushing' ,
208
+ async ( node ) => {
209
+ if ( ! CloudSketchbookTree . CloudSketchTreeNode . isSynced ( node ) ) {
210
+ throw new Error (
211
+ nls . localize (
212
+ 'arduino/cloud/pullFirst' ,
213
+ 'You have to pull first to be able to push to the Cloud.'
214
+ )
215
+ ) ;
216
+ }
217
+ const commandsCopy = node . commands ;
218
+ node . commands = [ ] ;
209
219
210
- const localUri = await this . fileService . toUnderlyingResource (
211
- LocalCacheUri . root . resolve ( node . remoteUri . path )
212
- ) ;
213
- await this . sync ( localUri , node . remoteUri ) ;
220
+ const localUri = await this . fileService . toUnderlyingResource (
221
+ LocalCacheUri . root . resolve ( node . remoteUri . path )
222
+ ) ;
223
+ await this . sync ( localUri , node . remoteUri ) ;
214
224
215
- this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
225
+ this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
216
226
217
- node . commands = commandsCopy ;
218
- this . messageService . info (
219
- nls . localize (
220
- 'arduino/cloud/donePushing' ,
221
- "Done pushing '{0}'." ,
222
- node . fileStat . name
223
- ) ,
224
- {
225
- timeout : MESSAGE_TIMEOUT ,
226
- }
227
- ) ;
228
- } ) ;
227
+ node . commands = commandsCopy ;
228
+ this . messageService . info (
229
+ nls . localize (
230
+ 'arduino/cloud/donePushing' ,
231
+ "Done pushing '{0}'." ,
232
+ node . fileStat . name
233
+ ) ,
234
+ {
235
+ timeout : MESSAGE_TIMEOUT ,
236
+ }
237
+ ) ;
238
+ } ,
239
+ noProgress
240
+ ) ;
229
241
}
230
242
231
243
private async recursiveURIs ( uri : URI ) : Promise < URI [ ] > {
@@ -328,8 +340,12 @@ export class CloudSketchbookTree extends SketchbookTree {
328
340
private async runWithState < T > (
329
341
node : CloudSketchbookTree . CloudSketchDirNode & Partial < DecoratedTreeNode > ,
330
342
state : CloudSketchbookTree . CloudSketchDirNode . State ,
331
- task : ( node : CloudSketchbookTree . CloudSketchDirNode ) => MaybePromise < T >
343
+ task : ( node : CloudSketchbookTree . CloudSketchDirNode ) => MaybePromise < T > ,
344
+ noProgress = false
332
345
) : Promise < T > {
346
+ if ( noProgress ) {
347
+ return task ( node ) ;
348
+ }
333
349
const name = node . uri . path . name ;
334
350
return ExecuteWithProgress . withProgress (
335
351
this . taskMessage ( state , name ) ,
@@ -346,8 +362,6 @@ export class CloudSketchbookTree extends SketchbookTree {
346
362
input : string
347
363
) : string {
348
364
switch ( state ) {
349
- case 'syncing' :
350
- return synchronizingSketchbook ;
351
365
case 'pulling' :
352
366
return pullingSketch ( input ) ;
353
367
case 'pushing' :
@@ -678,6 +692,6 @@ export namespace CloudSketchbookTree {
678
692
return SketchbookTree . SketchDirNode . is ( node ) ;
679
693
}
680
694
681
- export type State = 'syncing' | ' pulling' | 'pushing' ;
695
+ export type State = 'pulling' | 'pushing' ;
682
696
}
683
697
}
0 commit comments