-
-
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 2 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 |
---|---|---|
|
@@ -47,7 +47,8 @@ export class ProjectChangesService implements IProjectChangesService { | |
constructor( | ||
private $platformsData: IPlatformsData, | ||
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, | ||
private $fs: IFileSystem) { | ||
private $fs: IFileSystem, | ||
private $hostInfo: IHostInfo) { | ||
} | ||
|
||
public get currentChanges(): IProjectChangesInfo { | ||
|
@@ -227,10 +228,15 @@ 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 (this.$hostInfo.isDarwin && !fileStats.isDirectory() && !changed) { | ||
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 only for darwin? The case is for the File System itself, not the OS, so it may happen on different OSes. 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. I agree with you, but I don't know a trivial way of finding out what operating system is the code running on. That's why I check for darwin, because that's where the problem presents itself. |
||
const parentDirPath: string = path.dirname(filePath); | ||
const parentDirStat = this.$fs.getFsStats(parentDirPath); | ||
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. In case we have 50 files in the current dir and nothing is changed (including the parent dir), we'll get the stats of the parent directory 50 times.
We'll call 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. @rosen-vladimirov I did this as a temporary solution because I needed to test the fix on Mac and I needed to pull the code from it. I'm sorry if I inconvenienced you. I'm currently working on an optimized, permanent solution and will ping you when ready. |
||
|
||
changed = parentDirStat.mtime.getTime() > this._outputProjectMtime || | ||
parentDirStat.ctime.getTime() >= this._outputProjectCTime; | ||
} | ||
|
||
if (changed) { | ||
|
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.