From 8e489350aba9d420601a70707deb2bf213f587f3 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 14 Feb 2017 15:14:02 +0200 Subject: [PATCH 1/4] 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. --- lib/services/livesync/platform-livesync-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/services/livesync/platform-livesync-service.ts b/lib/services/livesync/platform-livesync-service.ts index 4754dcfa79..a7f85aa60e 100644 --- a/lib/services/livesync/platform-livesync-service.ts +++ b/lib/services/livesync/platform-livesync-service.ts @@ -2,6 +2,7 @@ import syncBatchLib = require("../../common/services/livesync/sync-batch"); import * as path from "path"; import * as minimatch from "minimatch"; import * as util from "util"; +import * as helpers from "../../common/helpers"; const livesyncInfoFileName = ".nslivesyncinfo"; @@ -223,7 +224,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe private async getLiveSyncInfoFilePath(deviceAppData: Mobile.IDeviceAppData): Promise { let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath()); - let deviceFilePath = path.join(deviceRootPath, livesyncInfoFileName); + let deviceFilePath =helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, livesyncInfoFileName)); return deviceFilePath; } From 54ff7dcf7fc05e4a886c6280abb6640190f58dee Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 15 Feb 2017 12:17:51 +0200 Subject: [PATCH 2/4] 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. --- lib/services/platform-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index aabf8fcf5e..efd13a8ec6 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -503,7 +503,7 @@ export class PlatformService implements IPlatformService { private async getDeviceBuildInfoFilePath(device: Mobile.IDevice): Promise { let deviceAppData = this.$deviceAppDataFactory.create(this.$projectData.projectId, device.deviceInfo.platform, device); let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath()); - return path.join(deviceRootPath, buildInfoFileName); + return helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, buildInfoFileName)); } private async getDeviceBuildInfo(device: Mobile.IDevice): Promise { From 89cfab712d7e7ff9cd0f20191e9a2afc4f2c05f9 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 16 Feb 2017 14:00:20 +0200 Subject: [PATCH 3/4] 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: https://github.com/telerik/mobile-cli-lib/pull/892 --- lib/services/project-changes-service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index d1be43fdc2..27fd8d69db 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -33,6 +33,7 @@ export class ProjectChangesService implements IProjectChangesService { private _prepareInfo: IPrepareInfo; private _newFiles: number = 0; private _outputProjectMtime: number; + private _outputProjectCTime: number; constructor( private $platformsData: IPlatformsData, @@ -140,6 +141,7 @@ export class ProjectChangesService implements IProjectChangesService { let platformData = this.$platformsData.getPlatformData(platform); let prepareInfoFile = path.join(platformData.projectRoot, prepareInfoFileName); this._outputProjectMtime = this.$fs.getFsStats(prepareInfoFile).mtime.getTime(); + this._outputProjectCTime = this.$fs.getFsStats(prepareInfoFile).ctime.getTime(); return false; } this._prepareInfo = { @@ -150,6 +152,7 @@ export class ProjectChangesService implements IProjectChangesService { changesRequireBuildTime: null }; this._outputProjectMtime = 0; + this._outputProjectCTime = 0; this._changesInfo.appFilesChanged = true; this._changesInfo.appResourcesChanged = true; this._changesInfo.modulesChanged = true; @@ -161,7 +164,7 @@ export class ProjectChangesService implements IProjectChangesService { for (let file of files) { if (this.$fs.exists(file)) { let fileStats = this.$fs.getFsStats(file); - if (fileStats.mtime.getTime() > this._outputProjectMtime) { + if (fileStats.mtime.getTime() >= this._outputProjectMtime || fileStats.ctime.getTime() >= this._outputProjectCTime) { return true; } } @@ -179,11 +182,10 @@ export class ProjectChangesService implements IProjectChangesService { let fileStats = this.$fs.getFsStats(filePath); - let changed = fileStats.mtime.getTime() > this._outputProjectMtime || fileStats.ctime.getTime() > this._outputProjectMtime; - + let changed = fileStats.mtime.getTime() >= this._outputProjectMtime || fileStats.ctime.getTime() >= this._outputProjectCTime; if (!changed) { let lFileStats = this.$fs.getLsStats(filePath); - changed = lFileStats.mtime.getTime() > this._outputProjectMtime || lFileStats.ctime.getTime() > this._outputProjectMtime; + changed = lFileStats.mtime.getTime() >= this._outputProjectMtime || lFileStats.ctime.getTime() >= this._outputProjectCTime; } if (changed) { From ba6386b5f99518e932384b1e1a8740053c3cf512 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 16 Feb 2017 17:46:28 +0200 Subject: [PATCH 4/4] Update to latest common lib --- lib/common | 2 +- lib/services/livesync/platform-livesync-service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common b/lib/common index e42406169d..1ecec5d2cf 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit e42406169d8231b4fc1ddbd40dcc947df8f915e2 +Subproject commit 1ecec5d2cf5f242d2c87345d68022ecbcd35927c diff --git a/lib/services/livesync/platform-livesync-service.ts b/lib/services/livesync/platform-livesync-service.ts index a7f85aa60e..316b2f269b 100644 --- a/lib/services/livesync/platform-livesync-service.ts +++ b/lib/services/livesync/platform-livesync-service.ts @@ -224,7 +224,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe private async getLiveSyncInfoFilePath(deviceAppData: Mobile.IDeviceAppData): Promise { let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath()); - let deviceFilePath =helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, livesyncInfoFileName)); + let deviceFilePath = helpers.fromWindowsRelativePathToUnix(path.join(deviceRootPath, livesyncInfoFileName)); return deviceFilePath; }