The Wayback Machine - https://web.archive.org/web/20201111155215/https://github.com/aspnet/FileSystem/issues/248
Skip to content
This repository has been archived by the owner. It is now read-only.

Inconsistent behaviour between GetFileInfo & Watch #248

Closed
ycrumeyrolle opened this issue Nov 25, 2016 · 3 comments
Closed

Inconsistent behaviour between GetFileInfo & Watch #248

ycrumeyrolle opened this issue Nov 25, 2016 · 3 comments

Comments

@ycrumeyrolle
Copy link

@ycrumeyrolle ycrumeyrolle commented Nov 25, 2016

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.

@muratg
Copy link

@muratg muratg commented Mar 20, 2017

@pranavkm thoughts?

@pranavkm
Copy link
Member

@pranavkm pranavkm commented Mar 20, 2017

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.

@muratg muratg added this to the 2.2.0 milestone Nov 16, 2017
@aspnet-hello
Copy link

@aspnet-hello aspnet-hello commented Jan 1, 2018

This issue was moved to aspnet/Home#2546

@aspnet aspnet locked and limited conversation to collaborators Jan 1, 2018
@aspnet-hello aspnet-hello removed this from the 2.2.0 milestone Jan 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.