@@ -37,10 +37,14 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
37
37
liveSyncData : ILiveSyncInfo ) : Promise < void > {
38
38
// TODO: Initialize devicesService before that.
39
39
const projectData = this . $projectDataService . getProjectData ( liveSyncData . projectDir ) ;
40
-
40
+ // In case liveSync is called for a second time for the same projectDir.
41
+ const isAlreadyLiveSyncing = this . liveSyncProcessesInfo [ projectData . projectDir ] && ! this . liveSyncProcessesInfo [ projectData . projectDir ] . isStopped ;
41
42
this . setLiveSyncProcessInfo ( liveSyncData . projectDir , deviceDescriptors ) ;
42
43
43
- await this . initialSync ( projectData , deviceDescriptors , liveSyncData ) ;
44
+ // TODO: Check if the _.difference actually works.
45
+ const deviceDescriptorsForInitialSync = isAlreadyLiveSyncing ? _ . difference ( deviceDescriptors , this . liveSyncProcessesInfo [ projectData . projectDir ] . deviceDescriptors ) : deviceDescriptors ;
46
+
47
+ await this . initialSync ( projectData , deviceDescriptorsForInitialSync , liveSyncData ) ;
44
48
45
49
if ( ! liveSyncData . skipWatcher && deviceDescriptors && deviceDescriptors . length ) {
46
50
// Should be set after prepare
@@ -169,9 +173,6 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
169
173
const preparedPlatforms : string [ ] = [ ] ;
170
174
const rebuiltInformation : ILiveSyncBuildInfo [ ] = [ ] ;
171
175
172
- // Prevent cases where liveSync is called consecutive times with the same device, for example [ A, B, C ] and then [ A, B, D ] - we want to execute initialSync only for D.
173
- const deviceDescriptorsForExecution = _ . difference ( deviceDescriptors , this . liveSyncProcessesInfo [ liveSyncData . projectDir ] . deviceDescriptors ) ;
174
-
175
176
// Now fullSync
176
177
const deviceAction = async ( device : Mobile . IDevice ) : Promise < void > => {
177
178
try {
@@ -204,7 +205,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
204
205
205
206
// Execute the action only on the deviceDescriptors passed to initialSync.
206
207
// In case where we add deviceDescriptors to already running application, we've already executed initialSync for them.
207
- await this . addActionToChain ( projectData . projectDir , ( ) => this . $devicesService . execute ( deviceAction , ( device : Mobile . IDevice ) => _ . some ( deviceDescriptorsForExecution , deviceDescriptor => deviceDescriptor . identifier === device . deviceInfo . identifier ) ) ) ;
208
+ await this . addActionToChain ( projectData . projectDir , ( ) => this . $devicesService . execute ( deviceAction , ( device : Mobile . IDevice ) => _ . some ( deviceDescriptors , deviceDescriptor => deviceDescriptor . identifier === device . deviceInfo . identifier ) ) ) ;
208
209
}
209
210
210
211
private async startWatcher ( projectData : IProjectData ,
0 commit comments