Exemplo n.º 1
0
        public void ReportFileSystemChanged(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            var monitorPath = !IgnorePatterns.ShouldIgnore(path);

            // Ignore certain files
            var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList();

            // If the parent of an ignored path has a change event, ignore that too
            if (tempIgnorePaths.Any(i =>
            {
                if (_fileSystem.AreEqual(i, path))
                {
                    _logger.LogDebug("Ignoring change to {Path}", path);
                    return(true);
                }

                if (_fileSystem.ContainsSubPath(i, path))
                {
                    _logger.LogDebug("Ignoring change to {Path}", path);
                    return(true);
                }

                // Go up a level
                var parent = Path.GetDirectoryName(i);
                if (!string.IsNullOrEmpty(parent) && _fileSystem.AreEqual(parent, path))
                {
                    _logger.LogDebug("Ignoring change to {Path}", path);
                    return(true);
                }

                return(false);
            }))
            {
                monitorPath = false;
            }

            if (monitorPath)
            {
                // Avoid implicitly captured closure
                CreateRefresher(path);
            }
        }
Exemplo n.º 2
0
 // This test is pending an upstream fix: https://github.com/dazinator/DotNet.Glob/issues/78
 // [InlineData("/media/music/Foo B.A.R.", false)]
 public void PathIgnored(string path, bool expected)
 {
     Assert.Equal(expected, IgnorePatterns.ShouldIgnore(path));
 }