Skip to content

Commit

Permalink
Merge pull request #1190 from NativeScript/fatme/respect-deleted-files
Browse files Browse the repository at this point in the history
Respect deleted files by livesync command
  • Loading branch information
Fatme authored and Fatme committed Nov 16, 2015
2 parents fed257f + 358da57 commit 9e372a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/common
25 changes: 24 additions & 1 deletion lib/services/usb-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
return this.$iOSEmulatorServices.postDarwinNotification(this.$iOSNotification.attachRequest);
}

public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
return (() => {
_.each(localToDevicePaths, localToDevicePathData => {
this.device.fileSystem.deleteFile(localToDevicePathData.getDevicePath(), appIdentifier);
});
}).future<void>()();
}

private sendPageReloadMessage(socket: net.Socket): void {
try {
this.sendPageReloadMessageCore(socket);
Expand Down Expand Up @@ -265,7 +273,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android

public beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): IFuture<void> {
return (() => {
let deviceRootPath = `/data/local/tmp/${deviceAppData.appIdentifier}`;
let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier);
this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"),
this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"),
this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait();
Expand All @@ -279,6 +287,21 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
}).future<void>()();
}

public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
return (() => {
let deviceRootPath = this.getDeviceRootPath(appIdentifier);
_.each(localToDevicePaths, localToDevicePathData => {
let relativeUnixPath = _.trimLeft(helpers.fromWindowsRelativePathToUnix(localToDevicePathData.getRelativeToProjectBasePath()), "/");
let deviceFilePath = this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync", relativeUnixPath);
this.device.adb.executeShellCommand(["mkdir", "-p", path.dirname(deviceFilePath), "&&", "touch", deviceFilePath]).wait();
});
}).future<void>()();
}

private getDeviceRootPath(appIdentifier: string): string {
return `/data/local/tmp/${appIdentifier}`;
}

private sendPageReloadMessage(): IFuture<void> {
let future = new Future<void>();

Expand Down

0 comments on commit 9e372a8

Please sign in to comment.