@@ -142,29 +142,33 @@ export class CloudSketchbookTree extends SketchbookTree {
142
142
node ,
143
143
'pull' ,
144
144
async ( node ) => {
145
- const commandsCopy = node . commands ;
146
- node . commands = [ ] ;
145
+ await this . pullNode ( node ) ;
146
+ } ,
147
+ noProgress
148
+ ) ;
149
+ }
147
150
148
- const localUri = await this . fileService . toUnderlyingResource (
149
- LocalCacheUri . root . resolve ( node . remoteUri . path )
150
- ) ;
151
- await this . sync ( node . remoteUri , localUri ) ;
151
+ private async pullNode ( node : CloudSketchbookTree . CloudSketchDirNode ) {
152
+ const commandsCopy = node . commands ;
153
+ node . commands = [ ] ;
152
154
153
- this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
155
+ const localUri = await this . fileService . toUnderlyingResource (
156
+ LocalCacheUri . root . resolve ( node . remoteUri . path )
157
+ ) ;
158
+ await this . sync ( node . remoteUri , localUri ) ;
154
159
155
- node . commands = commandsCopy ;
156
- this . messageService . info (
157
- nls . localize (
158
- 'arduino/cloud/donePulling' ,
159
- "Done pulling '{0}'." ,
160
- node . fileStat . name
161
- ) ,
162
- {
163
- timeout : MESSAGE_TIMEOUT ,
164
- }
165
- ) ;
166
- } ,
167
- noProgress
160
+ this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
161
+
162
+ node . commands = commandsCopy ;
163
+ this . messageService . info (
164
+ nls . localize (
165
+ 'arduino/cloud/donePulling' ,
166
+ "Done pulling '{0}'." ,
167
+ node . fileStat . name
168
+ ) ,
169
+ {
170
+ timeout : MESSAGE_TIMEOUT ,
171
+ }
168
172
) ;
169
173
}
170
174
@@ -210,37 +214,41 @@ export class CloudSketchbookTree extends SketchbookTree {
210
214
node ,
211
215
'push' ,
212
216
async ( node ) => {
213
- if ( ! CloudSketchbookTree . CloudSketchTreeNode . isSynced ( node ) ) {
214
- throw new Error (
215
- nls . localize (
216
- 'arduino/cloud/pullFirst' ,
217
- 'You have to pull first to be able to push to the Cloud.'
218
- )
219
- ) ;
220
- }
221
- const commandsCopy = node . commands ;
222
- node . commands = [ ] ;
217
+ await this . pushNode ( node ) ;
218
+ } ,
219
+ noProgress
220
+ ) ;
221
+ }
223
222
224
- const localUri = await this . fileService . toUnderlyingResource (
225
- LocalCacheUri . root . resolve ( node . remoteUri . path )
226
- ) ;
227
- await this . sync ( localUri , node . remoteUri ) ;
223
+ private async pushNode ( node : CloudSketchbookTree . CloudSketchDirNode ) {
224
+ if ( ! CloudSketchbookTree . CloudSketchTreeNode . isSynced ( node ) ) {
225
+ throw new Error (
226
+ nls . localize (
227
+ 'arduino/cloud/pullFirst' ,
228
+ 'You have to pull first to be able to push to the Cloud.'
229
+ )
230
+ ) ;
231
+ }
232
+ const commandsCopy = node . commands ;
233
+ node . commands = [ ] ;
228
234
229
- this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
235
+ const localUri = await this . fileService . toUnderlyingResource (
236
+ LocalCacheUri . root . resolve ( node . remoteUri . path )
237
+ ) ;
238
+ await this . sync ( localUri , node . remoteUri ) ;
230
239
231
- node . commands = commandsCopy ;
232
- this . messageService . info (
233
- nls . localize (
234
- 'arduino/cloud/donePushing' ,
235
- "Done pushing '{0}'." ,
236
- node . fileStat . name
237
- ) ,
238
- {
239
- timeout : MESSAGE_TIMEOUT ,
240
- }
241
- ) ;
242
- } ,
243
- noProgress
240
+ this . createApi . sketchCache . purgeByPath ( node . remoteUri . path . toString ( ) ) ;
241
+
242
+ node . commands = commandsCopy ;
243
+ this . messageService . info (
244
+ nls . localize (
245
+ 'arduino/cloud/donePushing' ,
246
+ "Done pushing '{0}'." ,
247
+ node . fileStat . name
248
+ ) ,
249
+ {
250
+ timeout : MESSAGE_TIMEOUT ,
251
+ }
244
252
) ;
245
253
}
246
254
0 commit comments