Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion GVFS/GVFS.FunctionalTests/Tests/GitCommands/GitRepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,12 @@ protected void CreateFileWithoutClose(string path)
this.FileSystem.CreateFileWithoutClose(controlFile);
}

protected void OpenFileAndWriteWithoutClose(string path, string contents)
protected void ReadFileAndWriteWithoutClose(string path, string contents)
{
string virtualFile = Path.Combine(this.Enlistment.RepoRoot, path);
string controlFile = Path.Combine(this.ControlGitRepo.RootPath, path);
this.FileSystem.ReadAllText(virtualFile);
this.FileSystem.ReadAllText(controlFile);
this.FileSystem.OpenFileAndWriteWithoutClose(virtualFile, contents);
this.FileSystem.OpenFileAndWriteWithoutClose(controlFile, contents);
}
Expand Down
3 changes: 1 addition & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/StatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ public void CreateFileWithoutClose()
this.ValidateGitCommand("status");
}

[Ignore("This test exposes a bug we don't yet have a fix for")]
[TestCase]
public void WriteWithoutClose()
{
string srcPath = @"Readme.md";
this.OpenFileAndWriteWithoutClose(srcPath, "More Stuff");
this.ReadFileAndWriteWithoutClose(srcPath, "More Stuff");
this.ValidateGitCommand("status");
}

Expand Down
21 changes: 8 additions & 13 deletions GVFS/GVFS.Platform.Mac/MacFileSystemVirtualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ protected override bool TryStart(out string error)
this.virtualizationInstance.OnPreDelete = this.OnPreDelete;
this.virtualizationInstance.OnNewFileCreated = this.OnNewFileCreated;
this.virtualizationInstance.OnFileRenamed = this.OnFileRenamed;
this.virtualizationInstance.OnHardLinkCreated = this.OnHardLinkCreated;
this.virtualizationInstance.OnHardLinkCreated = this.OnHardLinkCreated;
this.virtualizationInstance.OnFilePreConvertToFull = this.NotifyFilePreConvertToFull;

uint threadCount = (uint)Environment.ProcessorCount * 2;

Expand Down Expand Up @@ -437,24 +438,18 @@ private void OnFileModified(string relativePath)
{
this.OnDotGitFileOrFolderChanged(relativePath);
}
else
{
// TODO(Mac): As a temporary work around (until we have a ConvertToFull type notification) treat every modification
// as the first write to the file
bool isFolder;
string fileName;
bool isPathProjected = this.FileSystemCallbacks.GitIndexProjection.IsPathProjected(relativePath, out fileName, out isFolder);
if (isPathProjected)
{
this.FileSystemCallbacks.OnFileConvertedToFull(relativePath);
}
}
}
catch (Exception e)
{
this.LogUnhandledExceptionAndExit(nameof(this.OnFileModified), this.CreateEventMetadata(relativePath, e));
}
}

private Result NotifyFilePreConvertToFull(string relativePath)
{
this.OnFilePreConvertToFull(relativePath);
return Result.Success;
}

private Result OnPreDelete(string relativePath, bool isDirectory)
{
Expand Down
16 changes: 1 addition & 15 deletions GVFS/GVFS.Platform.Windows/WindowsFileSystemVirtualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,21 +1264,7 @@ private void NotifyFileHandleClosedFileModifiedOrDeletedHandler(

private HResult NotifyFilePreConvertToFullHandler(string virtualPath)
{
try
{
bool isFolder;
string fileName;
bool isPathProjected = this.FileSystemCallbacks.GitIndexProjection.IsPathProjected(virtualPath, out fileName, out isFolder);
if (isPathProjected)
{
this.FileSystemCallbacks.OnFileConvertedToFull(virtualPath);
}
}
catch (Exception e)
{
this.LogUnhandledExceptionAndExit(nameof(this.NotifyFilePreConvertToFullHandler), this.CreateEventMetadata(virtualPath, e));
}

this.OnFilePreConvertToFull(virtualPath);
return HResult.Ok;
}

Expand Down
18 changes: 18 additions & 0 deletions GVFS/GVFS.Virtualization/FileSystem/FileSystemVirtualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,24 @@ protected void OnHardLinkCreated(string relativeExistingFilePath, string relativ
}
}

protected void OnFilePreConvertToFull(string relativePath)
{
try
{
bool isFolder;
string fileName;
bool isPathProjected = this.FileSystemCallbacks.GitIndexProjection.IsPathProjected(relativePath, out fileName, out isFolder);
if (isPathProjected)
{
this.FileSystemCallbacks.OnFileConvertedToFull(relativePath);
}
}
catch (Exception e)
{
this.LogUnhandledExceptionAndExit(nameof(this.OnFilePreConvertToFull), this.CreateEventMetadata(relativePath, e));
}
}

protected EventMetadata CreateEventMetadata(
Guid enumerationId,
string relativePath = null,
Expand Down
7 changes: 7 additions & 0 deletions MirrorProvider/MirrorProvider.Mac/MacFileSystemVirtualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public override bool TryStartVirtualizationInstance(Enlistment enlistment, out s
this.virtualizationInstance.OnNewFileCreated = this.OnNewFileCreated;
this.virtualizationInstance.OnFileRenamed = this.OnFileRenamed;
this.virtualizationInstance.OnHardLinkCreated = this.OnHardLinkCreated;
this.virtualizationInstance.OnFilePreConvertToFull = this.OnFilePreConvertToFull;

Result result = this.virtualizationInstance.StartVirtualizationInstance(
enlistment.SrcRoot,
Expand Down Expand Up @@ -201,6 +202,12 @@ private void OnHardLinkCreated(string relativeNewLinkPath)
Console.WriteLine($"OnHardLinkCreated: {relativeNewLinkPath}");
}

private Result OnFilePreConvertToFull(string relativePath)
{
Console.WriteLine($"OnFilePreConvertToFull: {relativePath}");
return Result.Success;
}

private bool TryGetSymLinkTarget(string relativePath, out string symLinkTarget)
{
symLinkTarget = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override bool TryStartVirtualizationInstance(Enlistment enlistment, out s
this.virtualizationInstance.OnNotifyFileHandleClosedFileModifiedOrDeleted = this.OnFileModifiedOrDeleted;
this.virtualizationInstance.OnNotifyFileRenamed = this.OnFileRenamed;
this.virtualizationInstance.OnNotifyHardlinkCreated = this.OnHardlinkCreated;
this.virtualizationInstance.OnNotifyFilePreConvertToFull = this.OnFilePreConvertToFull;

uint threadCount = (uint)Environment.ProcessorCount * 2;

Expand Down Expand Up @@ -336,6 +337,12 @@ private void OnHardlinkCreated(
Console.WriteLine($"OnHardlinkCreated, relativeExistingFilePath: {relativeExistingFilePath}, relativeNewLinkFilePath: {relativeNewLinkFilePath}");
}

private HResult OnFilePreConvertToFull(string relativePath)
{
Console.WriteLine($"OnFilePreConvertToFullHandler: {relativePath}");
return HResult.Ok;
}

// TODO: Add this to the ProjFS API
private static HResult HResultFromWin32(int win32error)
{
Expand Down
Loading