@@ -36,14 +36,25 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
3636 `${ deviceProjectRootDirname } /sync` ]
3737 ) ;
3838
39+ await this . reloadResources ( deviceAppData , localToDevicePaths ) ;
40+
3941 const canExecuteFastSync = ! liveSyncInfo . isFullSync && ! _ . some ( localToDevicePaths ,
4042 ( localToDevicePath : Mobile . ILocalToDevicePathData ) => ! this . canExecuteFastSync ( localToDevicePath . getLocalPath ( ) , projectData , this . device . deviceInfo . platform ) ) ;
4143
42- if ( canExecuteFastSync ) {
43- return this . reloadPage ( deviceAppData , localToDevicePaths ) ;
44+ if ( ! canExecuteFastSync ) {
45+ return this . restartApplication ( deviceAppData ) ;
4446 }
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+ } ) ;
4554
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 ) ] ) ;
4758 }
4859
4960 private async restartApplication ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
@@ -70,15 +81,16 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
7081 await this . device . adb . executeShellCommand ( [ "rm" , "-f" , deviceRootPath ] ) ;
7182 }
7283
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 ) ;
7685 }
7786
78- private async reloadPage ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
87+ private async reloadResources ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
7988 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
8294 }
8395 }
8496
0 commit comments