Skip to content

Commit cf5e396

Browse files
tzraikovrosen-vladimirov
authored andcommitted
Fixed: getfile/putfile operate with global files (not local ones) (#2434)
1 parent b89d0b1 commit cf5e396

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
3838
if (await this.shouldTransferAllFiles(platform, deviceAppData)) {
3939
localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, null, this.liveSyncData.excludedProjectDirsAndFiles);
4040
await this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, true);
41-
await device.fileSystem.putFile(this.$projectChangesService.getPrepareInfoFilePath(platform), await this.getLiveSyncInfoFilePath(deviceAppData));
41+
await device.fileSystem.putFile(this.$projectChangesService.getPrepareInfoFilePath(platform), await this.getLiveSyncInfoFilePath(deviceAppData), appIdentifier);
4242
}
4343

4444
if (postAction) {
@@ -160,12 +160,14 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
160160
let deviceAppData: Mobile.IDeviceAppData = null;
161161
let localToDevicePaths: Mobile.ILocalToDevicePathData[] = null;
162162
let isFullSync = false;
163+
163164
if (this.$options.clean || this.$projectChangesService.currentChanges.changesRequireBuild) {
164165
let buildConfig: IBuildConfig = { buildForDevice: !device.isEmulator };
165166
let platform = device.deviceInfo.platform;
166167
if (this.$platformService.shouldBuild(platform, buildConfig)) {
167168
await this.$platformService.buildPlatform(platform, buildConfig);
168169
}
170+
169171
await this.$platformService.installApplication(device);
170172
deviceAppData = this.$deviceAppDataFactory.create(this.liveSyncData.appIdentifier, this.$mobileHelper.normalizePlatformName(this.liveSyncData.platform), device);
171173
isFullSync = true;
@@ -175,11 +177,15 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
175177
localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, this.liveSyncData.projectFilesPath, mappedFiles, this.liveSyncData.excludedProjectDirsAndFiles);
176178
await fileSyncAction(deviceAppData, localToDevicePaths);
177179
}
180+
178181
if (!afterFileSyncAction) {
179182
await this.refreshApplication(deviceAppData, localToDevicePaths, isFullSync);
180183
}
181-
await device.fileSystem.putFile(this.$projectChangesService.getPrepareInfoFilePath(device.deviceInfo.platform), await this.getLiveSyncInfoFilePath(deviceAppData));
184+
185+
await device.fileSystem.putFile(this.$projectChangesService.getPrepareInfoFilePath(device.deviceInfo.platform), await this.getLiveSyncInfoFilePath(deviceAppData), this.liveSyncData.appIdentifier);
186+
182187
await this.finishLivesync(deviceAppData);
188+
183189
if (afterFileSyncAction) {
184190
await afterFileSyncAction(deviceAppData, localToDevicePaths);
185191
}
@@ -203,11 +209,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
203209
}
204210

205211
private async getLiveSyncInfoFilePath(deviceAppData: Mobile.IDeviceAppData): Promise<string> {
206-
let deviceRootPath = await deviceAppData.getDeviceProjectRootPath();
207-
if (deviceAppData.device.deviceInfo.platform.toLowerCase() === this.$devicePlatformsConstants.Android.toLowerCase()) {
208-
deviceRootPath = path.dirname(deviceRootPath);
209-
}
210-
212+
let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath());
211213
let deviceFilePath = path.join(deviceRootPath, livesyncInfoFileName);
212214
return deviceFilePath;
213215
}

lib/services/platform-service.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,19 @@ export class PlatformService implements IPlatformService {
377377
} else {
378378
packageFile = this.getLatestApplicationPackageForDevice(platformData).packageName;
379379
}
380+
380381
await platformData.platformProjectService.deploy(device.deviceInfo.identifier);
382+
381383
await device.applicationManager.reinstallApplication(this.$projectData.projectId, packageFile);
384+
382385
if (!this.$options.release) {
383386
let deviceFilePath = await this.getDeviceBuildInfoFilePath(device);
384387
let buildInfoFilePath = this.getBuildOutputPath(device.deviceInfo.platform, platformData, { buildForDevice: !device.isEmulator });
385-
await device.fileSystem.putFile(path.join(buildInfoFilePath, buildInfoFileName), deviceFilePath);
388+
let appIdentifier = this.$projectData.projectId;
389+
390+
await device.fileSystem.putFile(path.join(buildInfoFilePath, buildInfoFileName), deviceFilePath, appIdentifier);
386391
}
392+
387393
this.$logger.out(`Successfully installed on device with identifier '${device.deviceInfo.identifier}'.`);
388394
}
389395

@@ -406,6 +412,7 @@ export class PlatformService implements IPlatformService {
406412
this.$logger.out("Skipping install.");
407413
}
408414
};
415+
409416
await this.$devicesService.execute(action, this.getCanExecuteAction(platform));
410417
}
411418

@@ -471,11 +478,7 @@ export class PlatformService implements IPlatformService {
471478

472479
private async getDeviceBuildInfoFilePath(device: Mobile.IDevice): Promise<string> {
473480
let deviceAppData = this.$deviceAppDataFactory.create(this.$projectData.projectId, device.deviceInfo.platform, device);
474-
let deviceRootPath = await deviceAppData.getDeviceProjectRootPath();
475-
if (device.deviceInfo.platform.toLowerCase() === this.$devicePlatformsConstants.Android.toLowerCase()) {
476-
deviceRootPath = path.dirname(deviceRootPath);
477-
}
478-
481+
let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath());
479482
return path.join(deviceRootPath, buildInfoFileName);
480483
}
481484

@@ -736,15 +739,17 @@ export class PlatformService implements IPlatformService {
736739
temp.track();
737740
let uniqueFilePath = temp.path({ suffix: ".tmp" });
738741
try {
739-
await device.fileSystem.getFile(deviceFilePath, uniqueFilePath);
742+
await device.fileSystem.getFile(deviceFilePath, this.$projectData.projectId, uniqueFilePath);
740743
} catch (e) {
741744
return null;
742745
}
746+
743747
if (this.$fs.exists(uniqueFilePath)) {
744748
let text = this.$fs.readText(uniqueFilePath);
745749
shell.rm(uniqueFilePath);
746750
return text;
747751
}
752+
748753
return null;
749754
}
750755
}

0 commit comments

Comments
 (0)