Skip to content

Commit e35de42

Browse files
authored
livesync deletes files and cleans temp folder afterwards (#3027)
* livesync deletes files and cleans temp folder afterwards * Add await for livesync reload files.
1 parent 0a7408a commit e35de42

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

lib/services/livesync/android-device-livesync-service.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -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

lib/services/livesync/platform-livesync-service-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export abstract class PlatformLiveSyncServiceBase {
9191
modifiedLocalToDevicePaths.push(...localToDevicePaths);
9292

9393
const deviceLiveSyncService = this.getDeviceLiveSyncService(device, projectData.projectId);
94-
deviceLiveSyncService.removeFiles(deviceAppData, localToDevicePaths);
94+
await deviceLiveSyncService.removeFiles(deviceAppData, localToDevicePaths);
9595
}
9696

9797
return {

0 commit comments

Comments
 (0)