@@ -24,12 +24,22 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
24
24
public async beforeLiveSyncAction ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
25
25
const platformData = this . $platformsData . getPlatformData ( deviceAppData . platform , this . data ) ;
26
26
const projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , APP_FOLDER_NAME ) ;
27
- await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
28
27
await this . device . applicationManager . startApplication ( { appId : deviceAppData . appIdentifier , projectName : this . data . projectName } ) ;
28
+ await this . connectLivesyncTool ( projectFilesPath , this . data . projectId ) ;
29
29
}
30
30
31
31
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 ( ) ;
33
43
}
34
44
35
45
public async removeFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < void > {
@@ -42,7 +52,7 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
42
52
if ( isFullSync ) {
43
53
transferredFiles = await this . _transferDirectory ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
44
54
} else {
45
- transferredFiles = this . _transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
55
+ transferredFiles = await this . _transferFiles ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
46
56
}
47
57
48
58
return transferredFiles ;
@@ -55,19 +65,32 @@ export class AndroidDeviceSocketsLiveSyncService extends DeviceLiveSyncServiceBa
55
65
}
56
66
57
67
private async _transferDirectory ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
68
+ let transferedFiles : Mobile . ILocalToDevicePathData [ ] ;
58
69
const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
59
70
const currentShasums : IStringDictionary = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
60
71
const oldShasums = await deviceHashService . getShasumsFromDevice ( ) ;
61
72
62
73
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 ;
66
77
} else {
67
78
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
+ }
70
91
}
92
+
93
+ return transferedFiles ;
71
94
}
72
95
73
96
private async connectLivesyncTool ( projectFilesPath : string , appIdentifier : string ) {
0 commit comments