@@ -37,10 +37,14 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
3737 liveSyncData : ILiveSyncInfo ) : Promise < void > {
3838 // TODO: Initialize devicesService before that.
3939 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 ;
4142 this . setLiveSyncProcessInfo ( liveSyncData . projectDir , deviceDescriptors ) ;
4243
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 ) ;
4448
4549 if ( ! liveSyncData . skipWatcher && deviceDescriptors && deviceDescriptors . length ) {
4650 // Should be set after prepare
@@ -169,9 +173,6 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
169173 const preparedPlatforms : string [ ] = [ ] ;
170174 const rebuiltInformation : ILiveSyncBuildInfo [ ] = [ ] ;
171175
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-
175176 // Now fullSync
176177 const deviceAction = async ( device : Mobile . IDevice ) : Promise < void > => {
177178 try {
@@ -204,7 +205,7 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
204205
205206 // Execute the action only on the deviceDescriptors passed to initialSync.
206207 // 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 ) ) ) ;
208209 }
209210
210211 private async startWatcher ( projectData : IProjectData ,
0 commit comments