-
-
Notifications
You must be signed in to change notification settings - Fork 197
make livesync work with renamed files and folders #3042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
94eeebb
d7f06d2
3692d8b
c861d06
3b8cb02
3c2713c
9020a86
f99697d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ export class ProjectChangesService implements IProjectChangesService { | |
path.join(projectData.projectDir, NODE_MODULES_FOLDER_NAME, "tns-ios-inspector"), | ||
projectData, | ||
this.fileChangeRequiresBuild); | ||
|
||
if (this._newFiles > 0) { | ||
this._changesInfo.modulesChanged = true; | ||
} | ||
|
@@ -218,6 +219,10 @@ export class ProjectChangesService implements IProjectChangesService { | |
} | ||
|
||
private containsNewerFiles(dir: string, skipDir: string, projectData: IProjectData, processFunc?: (filePath: string, projectData: IProjectData) => boolean): boolean { | ||
if (this.isDirectoryModified(dir)) { | ||
return true; | ||
} | ||
|
||
let files = this.$fs.readDirectory(dir); | ||
for (let file of files) { | ||
let filePath = path.join(dir, file); | ||
|
@@ -227,11 +232,8 @@ export class ProjectChangesService implements IProjectChangesService { | |
|
||
let fileStats = this.$fs.getFsStats(filePath); | ||
|
||
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._outputProjectCTime; | ||
} | ||
let changed = fileStats.mtime.getTime() > this._outputProjectMtime || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this without |
||
fileStats.ctime.getTime() >= this._outputProjectCTime; | ||
|
||
if (changed) { | ||
if (processFunc) { | ||
|
@@ -250,10 +252,17 @@ export class ProjectChangesService implements IProjectChangesService { | |
return true; | ||
} | ||
} | ||
|
||
} | ||
return false; | ||
} | ||
|
||
private isDirectoryModified(dirPath: string): boolean { | ||
const dirPathStat = this.$fs.getFsStats(dirPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is the same as the one used on line 235. Also the method is called |
||
return dirPathStat.mtime.getTime() > this._outputProjectMtime || | ||
dirPathStat.ctime.getTime() >= this._outputProjectCTime; | ||
} | ||
|
||
private fileChangeRequiresBuild(file: string, projectData: IProjectData) { | ||
if (path.basename(file) === "package.json") { | ||
return true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ import { PlatformsData } from "../lib/platforms-data"; | |
import { ProjectChangesService } from "../lib/services/project-changes-service"; | ||
import * as Constants from "../lib/constants"; | ||
import { FileSystem } from "../lib/common/file-system"; | ||
import * as HostInfoLib from "../lib/common/host-info"; | ||
import * as ErrorsLib from "../lib/common/errors"; | ||
|
||
// start tracking temporary folders/files | ||
temp.track(); | ||
|
@@ -26,7 +28,8 @@ class ProjectChangesServiceTest extends BaseServiceTest { | |
this.injector.register("platformsData", PlatformsData); | ||
this.injector.register("androidProjectService", {}); | ||
this.injector.register("iOSProjectService", {}); | ||
|
||
this.injector.register("hostInfo", HostInfoLib.HostInfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not used and shouldn't be added |
||
this.injector.register("errors", ErrorsLib.Errors); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not used and shouldn't be added |
||
this.injector.register("fs", FileSystem); | ||
this.injector.register("devicePlatformsConstants", {}); | ||
this.injector.register("devicePlatformsConstants", {}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this code deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unnecessary to do
this.$fs.getLsStats(filePath)
twice and the logic is kept the same in the refactored versionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getLstStats
andgetFsStats
are different. This code is used when the file/dir is symlink - we need to check the symlink itself (for example if it is recreated) and this is done bygetLsStats
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @Plamen5kov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will bring back the code, so we continue working with synlinked files.