Skip to content

Commit

Permalink
Account for corner case when fullPath matches root
Browse files Browse the repository at this point in the history
The previous buggy implementation of RenamedEventArgs
produced a convenient side-effect for PhysicalFilesWatcher.

Without the trailing slash adde by RenamedEventArgs the root
was longer than the fullPath by a trailing slash.

Fix dotnet#62606
  • Loading branch information
slask committed Dec 30, 2021
1 parent 0375648 commit decdc2b
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@ private void OnFileSystemEntryChange(string fullPath)
{
try
{
// this can happen when the fullPath matches the root directory path
// but the root path is always created with a trailing slash
// this was masked by a side effect (bug) in RenamedEventArgs that was appending the trailing slash to fullPath value
// that behavior was changed with the fix for https://github.com/dotnet/runtime/issues/62606
if (fullPath.Length < _root.Length)
{
return;
}

var fileSystemInfo = new FileInfo(fullPath);
if (FileSystemInfoHelper.IsExcluded(fileSystemInfo, _filters))
{
Expand Down

0 comments on commit decdc2b

Please sign in to comment.