Fix the prefix comparison
This commit is contained in:
parent
cf465b2001
commit
684ee87f20
|
|
@ -150,7 +150,8 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
|
|
||||||
private void RecordChange(FileSystemInfo fileInfo)
|
private void RecordChange(FileSystemInfo fileInfo)
|
||||||
{
|
{
|
||||||
if (_changes.Contains(fileInfo.FullName) ||
|
if (fileInfo == null ||
|
||||||
|
_changes.Contains(fileInfo.FullName) ||
|
||||||
fileInfo.FullName.Equals(_watchedDirectory.FullName, StringComparison.Ordinal))
|
fileInfo.FullName.Equals(_watchedDirectory.FullName, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Watcher.Core.Internal
|
namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
|
|
@ -39,6 +40,8 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
|
|
||||||
private void AddDirectoryWatcher(string directory)
|
private void AddDirectoryWatcher(string directory)
|
||||||
{
|
{
|
||||||
|
directory = EnsureTrailingSlash(directory);
|
||||||
|
|
||||||
var alreadyWatched = _watchers
|
var alreadyWatched = _watchers
|
||||||
.Where(d => directory.StartsWith(d.Key))
|
.Where(d => directory.StartsWith(d.Key))
|
||||||
.Any();
|
.Any();
|
||||||
|
|
@ -99,5 +102,16 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
throw new ObjectDisposedException(nameof(FileWatcher));
|
throw new ObjectDisposedException(nameof(FileWatcher));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string EnsureTrailingSlash(string path)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(path) &&
|
||||||
|
path[path.Length - 1] != Path.DirectorySeparatorChar)
|
||||||
|
{
|
||||||
|
return path + Path.DirectorySeparatorChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue