Skip to content

Commit f51608d

Browse files
author
Tsvetan Raikov
committed
Fixed slow livesync
1 parent aa81ea8 commit f51608d

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

lib/providers/device-app-data-provider.ts

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ export class IOSAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase imp
3131
return this.getDeviceProjectRootPath(this._deviceProjectRootPath);
3232
}
3333

34+
public get deviceSyncZipPath(): string {
35+
if (this.device.isEmulator) {
36+
return undefined;
37+
} else {
38+
return "Library/Application Support/LiveSync/sync.zip";
39+
}
40+
}
41+
3442
public isLiveSyncSupported(): IFuture<boolean> {
3543
return Future.fromResult(true);
3644
}

lib/providers/livesync-provider.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as path from "path";
2+
import * as temp from "temp";
23

34
export class LiveSyncProvider implements ILiveSyncProvider {
45
constructor(private $androidLiveSyncServiceLocator: {factory: Function},
56
private $iosLiveSyncServiceLocator: {factory: Function},
67
private $platformService: IPlatformService,
78
private $platformsData: IPlatformsData,
8-
private $logger: ILogger) { }
9+
private $logger: ILogger,
10+
private $childProcess: IChildProcess) { }
911

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

@@ -54,5 +56,25 @@ export class LiveSyncProvider implements ILiveSyncProvider {
5456
let fastSyncFileExtensions = LiveSyncProvider.FAST_SYNC_FILE_EXTENSIONS.concat(platformData.fastLivesyncFileExtensions);
5557
return _.contains(fastSyncFileExtensions, path.extname(filePath));
5658
}
59+
60+
public transferFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string, isFullSync: boolean): IFuture<void> {
61+
return (() => {
62+
if (deviceAppData.platform.toLowerCase() === "android" || !deviceAppData.deviceSyncZipPath || !isFullSync) {
63+
deviceAppData.device.fileSystem.transferFiles(deviceAppData, localToDevicePaths).wait();
64+
} else {
65+
temp.track();
66+
let tempZip = temp.path({prefix: "sync", suffix: ".zip"});
67+
this.$logger.trace("Creating zip file: " + tempZip);
68+
this.$childProcess.spawnFromEvent("zip", [ "-r", "-0", tempZip, "app" ], "close", { cwd: path.dirname(projectFilesPath) }).wait();
69+
70+
deviceAppData.device.fileSystem.transferFiles(deviceAppData, [{
71+
getLocalPath: () => tempZip,
72+
getDevicePath: () => deviceAppData.deviceSyncZipPath,
73+
getRelativeToProjectBasePath: () => "../sync.zip",
74+
deviceProjectRootPath: deviceAppData.deviceProjectRootPath
75+
}]).wait();
76+
}
77+
}).future<void>()();
78+
}
5779
}
5880
$injector.register("liveSyncProvider", LiveSyncProvider);

0 commit comments

Comments
 (0)