@@ -36,14 +36,25 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
36
36
`${ deviceProjectRootDirname } /sync` ]
37
37
) ;
38
38
39
+ await this . reloadResources ( deviceAppData , localToDevicePaths ) ;
40
+
39
41
const canExecuteFastSync = ! liveSyncInfo . isFullSync && ! _ . some ( localToDevicePaths ,
40
42
( localToDevicePath : Mobile . ILocalToDevicePathData ) => ! this . canExecuteFastSync ( localToDevicePath . getLocalPath ( ) , projectData , this . device . deviceInfo . platform ) ) ;
41
43
42
- if ( canExecuteFastSync ) {
43
- return this . reloadPage ( deviceAppData , localToDevicePaths ) ;
44
+ if ( ! canExecuteFastSync ) {
45
+ return this . restartApplication ( deviceAppData ) ;
44
46
}
47
+ }
48
+
49
+ private async cleanLivesyncDirectories ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
50
+ const deviceRootPath = await this . $devicePathProvider . getDeviceProjectRootPath ( deviceAppData . device , {
51
+ appIdentifier : deviceAppData . appIdentifier ,
52
+ getDirname : true
53
+ } ) ;
45
54
46
- return this . restartApplication ( deviceAppData ) ;
55
+ await this . device . adb . executeShellCommand ( [ "rm" , "-rf" , await this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . FULLSYNC_DIR_NAME ) ,
56
+ this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . SYNC_DIR_NAME ) ,
57
+ await this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . REMOVEDSYNC_DIR_NAME ) ] ) ;
47
58
}
48
59
49
60
private async restartApplication ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
@@ -70,15 +81,16 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
70
81
await this . device . adb . executeShellCommand ( [ "rm" , "-f" , deviceRootPath ] ) ;
71
82
}
72
83
73
- this . device . adb . executeShellCommand ( [ "rm" , "-rf" , this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . FULLSYNC_DIR_NAME ) ,
74
- this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . SYNC_DIR_NAME ) ,
75
- await this . $mobileHelper . buildDevicePath ( deviceRootPath , LiveSyncPaths . REMOVEDSYNC_DIR_NAME ) ] ) ;
84
+ await this . cleanLivesyncDirectories ( deviceAppData ) ;
76
85
}
77
86
78
- private async reloadPage ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
87
+ private async reloadResources ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
79
88
await this . device . adb . executeCommand ( [ "forward" , `tcp:${ AndroidDeviceLiveSyncService . BACKEND_PORT . toString ( ) } ` , `localabstract:${ deviceAppData . appIdentifier } -livesync` ] ) ;
80
- if ( ! await this . sendPageReloadMessage ( ) ) {
81
- await this . restartApplication ( deviceAppData ) ;
89
+
90
+ if ( await this . sendPageReloadMessage ( ) ) {
91
+ await this . cleanLivesyncDirectories ( deviceAppData ) ;
92
+ } else {
93
+ await this . restartApplication ( deviceAppData ) ; //in case runtime socket error/close
82
94
}
83
95
}
84
96
0 commit comments