Skip to content

Commit 9e372a8

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #1190 from NativeScript/fatme/respect-deleted-files
Respect deleted files by livesync command
2 parents fed257f + 358da57 commit 9e372a8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/services/usb-livesync-service.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
217217
return this.$iOSEmulatorServices.postDarwinNotification(this.$iOSNotification.attachRequest);
218218
}
219219

220+
public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
221+
return (() => {
222+
_.each(localToDevicePaths, localToDevicePathData => {
223+
this.device.fileSystem.deleteFile(localToDevicePathData.getDevicePath(), appIdentifier);
224+
});
225+
}).future<void>()();
226+
}
227+
220228
private sendPageReloadMessage(socket: net.Socket): void {
221229
try {
222230
this.sendPageReloadMessageCore(socket);
@@ -265,7 +273,7 @@ export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.Android
265273

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

290+
public removeFile(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
291+
return (() => {
292+
let deviceRootPath = this.getDeviceRootPath(appIdentifier);
293+
_.each(localToDevicePaths, localToDevicePathData => {
294+
let relativeUnixPath = _.trimLeft(helpers.fromWindowsRelativePathToUnix(localToDevicePathData.getRelativeToProjectBasePath()), "/");
295+
let deviceFilePath = this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync", relativeUnixPath);
296+
this.device.adb.executeShellCommand(["mkdir", "-p", path.dirname(deviceFilePath), "&&", "touch", deviceFilePath]).wait();
297+
});
298+
}).future<void>()();
299+
}
300+
301+
private getDeviceRootPath(appIdentifier: string): string {
302+
return `/data/local/tmp/${appIdentifier}`;
303+
}
304+
282305
private sendPageReloadMessage(): IFuture<void> {
283306
let future = new Future<void>();
284307

0 commit comments

Comments
 (0)