Fix the prefix comparison
This commit is contained in:
Родитель
cf465b2001
Коммит
684ee87f20
|
@ -150,7 +150,8 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
|||
|
||||
private void RecordChange(FileSystemInfo fileInfo)
|
||||
{
|
||||
if (_changes.Contains(fileInfo.FullName) ||
|
||||
if (fileInfo == null ||
|
||||
_changes.Contains(fileInfo.FullName) ||
|
||||
fileInfo.FullName.Equals(_watchedDirectory.FullName, StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||
|
@ -39,6 +40,8 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
|||
|
||||
private void AddDirectoryWatcher(string directory)
|
||||
{
|
||||
directory = EnsureTrailingSlash(directory);
|
||||
|
||||
var alreadyWatched = _watchers
|
||||
.Where(d => directory.StartsWith(d.Key))
|
||||
.Any();
|
||||
|
@ -99,5 +102,16 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче