@@ -24,12 +24,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
2424 public async beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
2525 const platformData = this . $platformsData . getPlatformData ( deviceAppData . platform , this . data ) ;
2626 const projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , APP_FOLDER_NAME ) ;
27- await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
2827 await this . device . applicationManager . startApplication ( { appId : deviceAppData . appIdentifier , projectName : this . data . projectName } ) ;
28+ await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
2929 }
3030
3131 public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) : Promise < void > {
32- await this . livesyncTool . sendDoSyncOperation ( )
32+ const canExecuteFastSync = ! liveSyncInfo . isFullSync && ! _ . some ( liveSyncInfo . modifiedFilesData ,
33+ ( localToDevicePath : Mobile . ILocalToDevicePathData ) => ! this . canExecuteFastSync ( localToDevicePath . getLocalPath ( ) , projectData , this . device . deviceInfo . platform ) ) ;
34+
35+ if ( ! canExecuteFastSync && liveSyncInfo . modifiedFilesData . length ) {
36+ await this . livesyncTool . sendDoSyncOperation ( ) ;
37+ await this . device . applicationManager . restartApplication ( { appId : liveSyncInfo . deviceAppData . appIdentifier , projectName : projectData . projectName } ) ;
38+ } else if ( liveSyncInfo . modifiedFilesData . length ) {
39+ await this . livesyncTool . sendDoSyncOperation ( ) ;
40+ }
41+
42+ this . livesyncTool . end ( ) ;
3343 }
3444
3545 public async removeFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < void > {
@@ -42,7 +52,7 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
4252 if ( isFullSync ) {
4353 transferredFiles = await this . _transferDirectory ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
4454 } else {
45- transferredFiles = this . _transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
55+ transferredFiles = await this . _transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
4656 }
4757
4858 return transferredFiles ;
@@ -55,19 +65,32 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
5565 }
5666
5767 private async _transferDirectory ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
68+ let transferedFiles : Mobile . ILocalToDevicePathData [ ] ;
5869 const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
5970 const currentShasums : IStringDictionary = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
6071 const oldShasums = await deviceHashService . getShasumsFromDevice ( ) ;
6172
6273 if ( this . $options . force || ! oldShasums ) {
63- this . livesyncTool . sendDirectory ( projectFilesPath ) ;
64-
65- return localToDevicePaths ;
74+ await this . livesyncTool . sendDirectory ( projectFilesPath ) ;
75+ await deviceHashService . uploadHashFileToDevice ( currentShasums ) ;
76+ transferedFiles = localToDevicePaths ;
6677 } else {
6778 const changedShasums = deviceHashService . getChnagedShasums ( oldShasums , currentShasums ) ;
68- await this . livesyncTool . sendFilesArray ( _ . map ( changedShasums , ( hash : string , pathToFile : string ) => pathToFile ) ) ;
69- await deviceHashService . uploadHashFileToDevice ( currentShasums ) ;
79+ const changedFiles = _ . map ( changedShasums , ( hash : string , pathToFile : string ) => pathToFile ) ;
80+ if ( changedFiles . length ) {
81+ await this . livesyncTool . sendFilesArray ( changedFiles ) ;
82+ await deviceHashService . uploadHashFileToDevice ( currentShasums ) ;
83+ transferedFiles = localToDevicePaths . filter ( localToDevicePathData => {
84+ if ( changedFiles . indexOf ( localToDevicePathData . getLocalPath ( ) ) >= 0 ) {
85+ return true ;
86+ }
87+ } ) ;
88+ } else {
89+ transferedFiles = [ ] ;
90+ }
7091 }
92+
93+ return transferedFiles ;
7194 }
7295
7396 private async connectLivesyncTool ( projectFilesPath : string , appIdentifier : string ) {
0 commit comments