Skip to content

Fixed slow livesync #1858

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

Merged
merged 1 commit into from
Jun 21, 2016
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
8 changes: 8 additions & 0 deletions lib/providers/device-app-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export class IOSAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase imp
return this.getDeviceProjectRootPath(this._deviceProjectRootPath);
}

public get deviceSyncZipPath(): string {
if (this.device.isEmulator) {
return undefined;
} else {
return "Library/Application Support/LiveSync/sync.zip";
}
}

public isLiveSyncSupported(): IFuture<boolean> {
return Future.fromResult(true);
}
Expand Down
24 changes: 23 additions & 1 deletion lib/providers/livesync-provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as path from "path";
import * as temp from "temp";

export class LiveSyncProvider implements ILiveSyncProvider {
constructor(private $androidLiveSyncServiceLocator: {factory: Function},
private $iosLiveSyncServiceLocator: {factory: Function},
private $platformService: IPlatformService,
private $platformsData: IPlatformsData,
private $logger: ILogger) { }
private $logger: ILogger,
private $childProcess: IChildProcess) { }

private static FAST_SYNC_FILE_EXTENSIONS = [".css", ".xml"];

Expand Down Expand Up @@ -54,5 +56,25 @@ export class LiveSyncProvider implements ILiveSyncProvider {
let fastSyncFileExtensions = LiveSyncProvider.FAST_SYNC_FILE_EXTENSIONS.concat(platformData.fastLivesyncFileExtensions);
return _.contains(fastSyncFileExtensions, path.extname(filePath));
}

public transferFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string, isFullSync: boolean): IFuture<void> {
return (() => {
if (deviceAppData.platform.toLowerCase() === "android" || !deviceAppData.deviceSyncZipPath || !isFullSync) {
deviceAppData.device.fileSystem.transferFiles(deviceAppData, localToDevicePaths).wait();
} else {
temp.track();
let tempZip = temp.path({prefix: "sync", suffix: ".zip"});
this.$logger.trace("Creating zip file: " + tempZip);
this.$childProcess.spawnFromEvent("zip", [ "-r", "-0", tempZip, "app" ], "close", { cwd: path.dirname(projectFilesPath) }).wait();

deviceAppData.device.fileSystem.transferFiles(deviceAppData, [{
getLocalPath: () => tempZip,
getDevicePath: () => deviceAppData.deviceSyncZipPath,
getRelativeToProjectBasePath: () => "../sync.zip",
deviceProjectRootPath: deviceAppData.deviceProjectRootPath
}]).wait();
}
}).future<void>()();
}
}
$injector.register("liveSyncProvider", LiveSyncProvider);