From 95efc68d2861c8d810931ec93022e31aaf1e39a1 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Wed, 2 Aug 2017 11:24:40 +0300 Subject: [PATCH 1/2] livesync deletes files and cleans temp folder afterwards --- .../android-device-livesync-service.ts | 30 +++++++++++++------ .../platform-livesync-service-base.ts | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/services/livesync/android-device-livesync-service.ts b/lib/services/livesync/android-device-livesync-service.ts index bf1c0edbd9..93e61b8238 100644 --- a/lib/services/livesync/android-device-livesync-service.ts +++ b/lib/services/livesync/android-device-livesync-service.ts @@ -36,14 +36,25 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl `${deviceProjectRootDirname}/sync`] ); + this.reloadResources(deviceAppData, localToDevicePaths); + const canExecuteFastSync = !liveSyncInfo.isFullSync && !_.some(localToDevicePaths, (localToDevicePath: Mobile.ILocalToDevicePathData) => !this.canExecuteFastSync(localToDevicePath.getLocalPath(), projectData, this.device.deviceInfo.platform)); - if (canExecuteFastSync) { - return this.reloadPage(deviceAppData, localToDevicePaths); + if (!canExecuteFastSync) { + return this.restartApplication(deviceAppData); } + } + + private async cleanLivesyncDirectories(deviceAppData: Mobile.IDeviceAppData): Promise { + const deviceRootPath = await this.$devicePathProvider.getDeviceProjectRootPath(deviceAppData.device, { + appIdentifier: deviceAppData.appIdentifier, + getDirname: true + }); - return this.restartApplication(deviceAppData); + await this.device.adb.executeShellCommand(["rm", "-rf", await this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.FULLSYNC_DIR_NAME), + this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.SYNC_DIR_NAME), + await this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.REMOVEDSYNC_DIR_NAME)]); } private async restartApplication(deviceAppData: Mobile.IDeviceAppData): Promise { @@ -70,15 +81,16 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl await this.device.adb.executeShellCommand(["rm", "-f", deviceRootPath]); } - this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.FULLSYNC_DIR_NAME), - this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.SYNC_DIR_NAME), - await this.$mobileHelper.buildDevicePath(deviceRootPath, LiveSyncPaths.REMOVEDSYNC_DIR_NAME)]); + await this.cleanLivesyncDirectories(deviceAppData); } - private async reloadPage(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise { + private async reloadResources(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise { await this.device.adb.executeCommand(["forward", `tcp:${AndroidDeviceLiveSyncService.BACKEND_PORT.toString()}`, `localabstract:${deviceAppData.appIdentifier}-livesync`]); - if (!await this.sendPageReloadMessage()) { - await this.restartApplication(deviceAppData); + + if (await this.sendPageReloadMessage()) { + await this.cleanLivesyncDirectories(deviceAppData); + } else { + await this.restartApplication(deviceAppData); //in case runtime socket error/close } } diff --git a/lib/services/livesync/platform-livesync-service-base.ts b/lib/services/livesync/platform-livesync-service-base.ts index c8beb26240..298d34c902 100644 --- a/lib/services/livesync/platform-livesync-service-base.ts +++ b/lib/services/livesync/platform-livesync-service-base.ts @@ -91,7 +91,7 @@ export abstract class PlatformLiveSyncServiceBase { modifiedLocalToDevicePaths.push(...localToDevicePaths); const deviceLiveSyncService = this.getDeviceLiveSyncService(device, projectData.projectId); - deviceLiveSyncService.removeFiles(deviceAppData, localToDevicePaths); + await deviceLiveSyncService.removeFiles(deviceAppData, localToDevicePaths); } return { From 8c35017f9dc5cc9404063d35b7812f24545f33b3 Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Fri, 4 Aug 2017 15:06:20 +0300 Subject: [PATCH 2/2] Add await for livesync reload files. --- lib/services/livesync/android-device-livesync-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/livesync/android-device-livesync-service.ts b/lib/services/livesync/android-device-livesync-service.ts index 93e61b8238..b50a35513e 100644 --- a/lib/services/livesync/android-device-livesync-service.ts +++ b/lib/services/livesync/android-device-livesync-service.ts @@ -36,7 +36,7 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl `${deviceProjectRootDirname}/sync`] ); - this.reloadResources(deviceAppData, localToDevicePaths); + await this.reloadResources(deviceAppData, localToDevicePaths); const canExecuteFastSync = !liveSyncInfo.isFullSync && !_.some(localToDevicePaths, (localToDevicePath: Mobile.ILocalToDevicePathData) => !this.canExecuteFastSync(localToDevicePath.getLocalPath(), projectData, this.device.deviceInfo.platform));