This commit is contained in:
Victor Hurdugaci 2016-04-18 16:57:52 -07:00
Родитель cf465b2001
Коммит 684ee87f20
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -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;
}
}
}