Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livesync deletes files and cleans temp folder afterwards #3027

Merged
merged 2 commits into from
Aug 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions lib/services/livesync/android-device-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,25 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
`${deviceProjectRootDirname}/sync`]
);

await 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<void> {
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<void> {
Expand All @@ -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<void> {
private async reloadResources(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
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
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/services/livesync/platform-livesync-service-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down