Skip to content

Commit 8110d11

Browse files
Merge LiveSync fixes from release branch (#2553)
* Fix uploading of .nsprepareinfo on Windows When `.nprepareinfo` file is uploaded on device, we construct the device file path with `path.join` function. On Windows this function returns path similar to `\\data\\local\\tmp`, which is not working for Unix based OSes (Android in this case). Fix this by converting the path to Unix style. * Fix uploading of .nsbuilinfo on Windows When `.npbuildnfo` file is uploaded on device, we construct the device file path with `path.join` function. On Windows this function returns path similar to `\\data\\local\\tmp`, which is not working for Unix based OSes (Android in this case). Fix this by converting the path to Unix style. * Fix ENOENT errors on macOS during livesync On macOS sometimes we recive ENOENT errors during livesync operations (`tns run ios`). This is due to the following: - incorrect detection if a file is modified - we check if the project dir's mTime and cTime values are bigger than the .nsprepareinfo. However in some cases they are equal, which means the dir has been modified in the same moment when the `.nsprepareinfo` is saved. In order to fix this, mark the files/dirs as modified in case the modified time of `.nsprepareinfo` and the respective file are the same. - In some cases we are not able to sync files to iOS Simulator as chokidar does not raise correct events on macOS when directory is renamed immediately after it's being created. After adding a file to this directory we throw ENOENT, as such dir does not exist in Simulator's dir. In order to fix this, ensure the directory exist in the simulator. PR in common-lib: telerik/mobile-cli-lib#892 * Update to latest common lib
1 parent 96ab06c commit 8110d11

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import syncBatchLib = require("../../common/services/livesync/sync-batch");
22
import * as path from "path";
33
import * as minimatch from "minimatch";
44
import * as util from "util";
5+
import * as helpers from "../../common/helpers";
56

67
const livesyncInfoFileName = ".nslivesyncinfo";
78

@@ -223,7 +224,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
223224

224225
private async getLiveSyncInfoFilePath(deviceAppData: Mobile.IDeviceAppData): Promise<string> {
225226
let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath());
226-
let deviceFilePath = path.join(deviceRootPath, livesyncInfoFileName);
227+
let deviceFilePath = helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, livesyncInfoFileName));
227228
return deviceFilePath;
228229
}
229230

lib/services/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ export class PlatformService implements IPlatformService {
503503
private async getDeviceBuildInfoFilePath(device: Mobile.IDevice): Promise<string> {
504504
let deviceAppData = this.$deviceAppDataFactory.create(this.$projectData.projectId, device.deviceInfo.platform, device);
505505
let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath());
506-
return path.join(deviceRootPath, buildInfoFileName);
506+
return helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, buildInfoFileName));
507507
}
508508

509509
private async getDeviceBuildInfo(device: Mobile.IDevice): Promise<IBuildInfo> {

lib/services/project-changes-service.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class ProjectChangesService implements IProjectChangesService {
3333
private _prepareInfo: IPrepareInfo;
3434
private _newFiles: number = 0;
3535
private _outputProjectMtime: number;
36+
private _outputProjectCTime: number;
3637

3738
constructor(
3839
private $platformsData: IPlatformsData,
@@ -140,6 +141,7 @@ export class ProjectChangesService implements IProjectChangesService {
140141
let platformData = this.$platformsData.getPlatformData(platform);
141142
let prepareInfoFile = path.join(platformData.projectRoot, prepareInfoFileName);
142143
this._outputProjectMtime = this.$fs.getFsStats(prepareInfoFile).mtime.getTime();
144+
this._outputProjectCTime = this.$fs.getFsStats(prepareInfoFile).ctime.getTime();
143145
return false;
144146
}
145147
this._prepareInfo = {
@@ -150,6 +152,7 @@ export class ProjectChangesService implements IProjectChangesService {
150152
changesRequireBuildTime: null
151153
};
152154
this._outputProjectMtime = 0;
155+
this._outputProjectCTime = 0;
153156
this._changesInfo.appFilesChanged = true;
154157
this._changesInfo.appResourcesChanged = true;
155158
this._changesInfo.modulesChanged = true;
@@ -161,7 +164,7 @@ export class ProjectChangesService implements IProjectChangesService {
161164
for (let file of files) {
162165
if (this.$fs.exists(file)) {
163166
let fileStats = this.$fs.getFsStats(file);
164-
if (fileStats.mtime.getTime() > this._outputProjectMtime) {
167+
if (fileStats.mtime.getTime() >= this._outputProjectMtime || fileStats.ctime.getTime() >= this._outputProjectCTime) {
165168
return true;
166169
}
167170
}
@@ -179,11 +182,10 @@ export class ProjectChangesService implements IProjectChangesService {
179182

180183
let fileStats = this.$fs.getFsStats(filePath);
181184

182-
let changed = fileStats.mtime.getTime() > this._outputProjectMtime || fileStats.ctime.getTime() > this._outputProjectMtime;
183-
185+
let changed = fileStats.mtime.getTime() >= this._outputProjectMtime || fileStats.ctime.getTime() >= this._outputProjectCTime;
184186
if (!changed) {
185187
let lFileStats = this.$fs.getLsStats(filePath);
186-
changed = lFileStats.mtime.getTime() > this._outputProjectMtime || lFileStats.ctime.getTime() > this._outputProjectMtime;
188+
changed = lFileStats.mtime.getTime() >= this._outputProjectMtime || lFileStats.ctime.getTime() >= this._outputProjectCTime;
187189
}
188190

189191
if (changed) {

0 commit comments

Comments
 (0)