Skip to content

Mac: File modified notifications#156

Merged
wilbaker merged 6 commits intomicrosoft:masterfrom
wilbaker:users/wilbaker/mac_file_modified_notification
Aug 13, 2018
Merged

Mac: File modified notifications#156
wilbaker merged 6 commits intomicrosoft:masterfrom
wilbaker:users/wilbaker/mac_file_modified_notification

Conversation

@wilbaker
Copy link
Member

@wilbaker wilbaker commented Aug 13, 2018

Part of the work required for #152

These changes add file modified notification handling to kernel and user mode code.

Additional functional tests have also been enabled:

Test Run Summary
  Overall result: Warning
  Test Count: 143, Passed: 141, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 2
    Skipped Tests - Ignored: 2, Explicit: 0, Other: 0
  Start time: 2018-08-13 22:00:15Z
    End time: 2018-08-13 22:11:28Z
    Duration: 672.380 seconds

@wilbaker wilbaker requested review from nickgra and sanoursa August 13, 2018 18:25
throw new InvalidOperationException(nameof(this.WriteToDisk) + " requires that collectionAppendsDirectlyToFile be true");
}

// TODO(Mac): Decide if we want to stick with \r\n on all platforms, move them all to \n, or use a mix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to keep this TODO? As far as I know, both Windows and Mac are happy with this format as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanoursa Good point, both platforms appear to be happy with it so we can take it out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

fileToOverwriteVirtualPath.ShouldBeAFile(this.fileSystem).WithContents(testContents);

GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToOverwriteEntry + Environment.NewLine);
// TODO(Mac): Switch from "\r\n" to Environment.NewLine or "\n" depending on how FileBasedCollection is updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

switch (Path.DirectorySeparatorChar)
{
case '/':
cleanedPath = path.Replace('\\', Path.DirectorySeparatorChar);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a bit worrisome - it seems like it could hide tests that are still assuming Windows slashes, rather than force us to clean up the tests.

I would expect this method to convert from Git paths to file system paths, but not to cover over platform-related differences. So to me, that means that it should do a conversion on Windows, and noop on Mac. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanoursa I went back and forth on this as well. I agree with your assessment that we might miss cleaning up tests with this change. I'll switch this to just convert Git path to system path.


ulong fileSize,
UInt16 fileMode);
ushort fileMode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why did you change this type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanoursa I had to update these types after enabling StyleCop for the project

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

OnGetFileStream = this.OnGetFileStream,

// Note: We must use this.notifyOperationCallback and not this.OnNotifyOperation
// to ensure we don't create a temporary delegate that will be garbage collected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make this more explicit in the code itself. Perhaps something like this?

OnNotifyOperation = (this.preventGCOnNotifyOperationDelegate = new NotifyOperationCallback(this.OnNotifyOperation)),

The root cause of the issue is that there is an implicit delegate allocation, so let's make at least that much of it explicit in the code. I think it would also be clearer to store that instance here, rather than in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanoursa

I think it would also be clearer to store that instance here, rather than in the constructor.

That sounds good to me (note that preventGCOnNotifyOperationDelegate will no longer be able to be readonly with this change).

@sanoursa
Copy link
Contributor

I had tested your last round of changes and it all worked great. I was able to write changes into a newly hydrated file, and git status picked up those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants