Inconsistent behaviour between GetFileInfo & Watch
ycrumeyrolle opened this issue · 3 comments
Take the following code :
ChangeToken.OnChange(() => _fileProvider.Watch(@".\test.txt"), FileChanged);
private void FileChanged()
{
var file = _fileProvider.GetFileInfo(@".\test.txt");
_fileExists = file != null && file.Exists;
}
Tried with a PhysicalFileProvider.
If I call the FileChanged()
method directly, the file provider is functioning properly and providing information on the file.
If I change the file, the change is not watched and the ChangeToken does not trigger.
If I update the code by removing the trailing .\
, the ChangeToken is also functioning properly :
ChangeToken.OnChange(() => _fileProvider.Watch("test.txt"), FileChanged);
private void FileChanged()
{
var file = _fileProvider.GetFileInfo("test.txt");
_fileExists = file != null && file.Exists;
}
The GetFileInfo do not consider the trailing .\
as invalid characters, but the Watch does.
Yeah, we should fix this. The issue is more pervasive and affect other relative paths for instance - /Views/Home/../Shared/_Layout.cshtml
is a valid rooted path, but Watch
doesn't work with this.
We workaround this in Mvc (aspnet/Mvc@cfa9631) primarily because we wanted the view engine to work in a file provider agnostic way, but it would be good to resolve paths in PhysicalFileProvider
too.
This issue was moved to aspnet/Home#2546