Skip to content

Commit ec05674

Browse files
committed
Delete /data/local/tmp/<app-identifier> file if exists on Android device
Livesync does not work when /data/local/tmp/<app-identifier> 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.
1 parent ea53638 commit ec05674

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/services/livesync/android-livesync-service.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ class AndroidLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<
3535

3636
public beforeLiveSyncAction(deviceAppData: Mobile.IDeviceAppData): IFuture<void> {
3737
return (() => {
38-
let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier);
38+
let deviceRootPath = this.getDeviceRootPath(deviceAppData.appIdentifier),
39+
deviceRootDir = path.dirname(deviceRootPath),
40+
deviceRootBasename = path.basename(deviceRootPath),
41+
listResult = this.device.adb.executeShellCommand(["ls", "-l", deviceRootDir]).wait(),
42+
regex = new RegExp(`^-.*${deviceRootBasename}$`, "m"),
43+
matchingFile = (listResult || "").match(regex);
44+
45+
// Check if there is already a file with deviceRootBasename. If so, delete it as it breaks LiveSyncing.
46+
if(matchingFile && matchingFile[0] && _.startsWith(matchingFile[0], '-')){
47+
this.device.adb.executeShellCommand(["rm", "-f", deviceRootPath]).wait();
48+
}
49+
3950
this.device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"),
4051
this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"),
4152
this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait();

0 commit comments

Comments
 (0)