From ec0567499514eabbb28c7ea0d1e75e5bdb9ecf56 Mon Sep 17 00:00:00 2001 From: Nadya Atanasova Date: Wed, 2 Mar 2016 13:13:21 +0200 Subject: [PATCH] Delete /data/local/tmp/ file if exists on Android device Livesync does not work when /data/local/tmp/ file exists on Android device. This happens when a file with name app-identifier exists in /data/local/tmp directory on device. In this case CLI is not able to create directory. --- lib/services/livesync/android-livesync-service.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/services/livesync/android-livesync-service.ts b/lib/services/livesync/android-livesync-service.ts index 27ca710432..0d3d6e3baf 100644 --- a/lib/services/livesync/android-livesync-service.ts +++ b/lib/services/livesync/android-livesync-service.ts @@ -35,7 +35,18 @@ class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase< public beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): IFuture { return (() => { - let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier); + let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier), + deviceRootDir = path.dirname(deviceRootPath), + deviceRootBasename = path.basename(deviceRootPath), + listResult = this.device.adb.executeShellCommand(["ls", "-l", deviceRootDir]).wait(), + regex = new RegExp(`^-.*${deviceRootBasename}$`, "m"), + matchingFile = (listResult || "").match(regex); + + // Check if there is already a file with deviceRootBasename. If so, delete it as it breaks LiveSyncing. + if(matchingFile && matchingFile[0] && _.startsWith(matchingFile[0], '-')){ + this.device.adb.executeShellCommand(["rm", "-f", deviceRootPath]).wait(); + } + this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"), this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"), this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait();