Skip to content

Commit 2b253ed

Browse files
Fix ENOENT errors on macOS during livesync (#2549)
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
1 parent ceb0660 commit 2b253ed

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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)