diff --git a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs index 855397a17..e513b4774 100644 --- a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.IO /// /// Any file name ending in any of these will be ignored by the watchers /// - private readonly List _alwaysIgnoreFiles = new List { "thumbs.db", "small.jpg", "albumart.jpg" }; + private readonly IReadOnlyList _alwaysIgnoreFiles = new List { "thumbs.db", "small.jpg", "albumart.jpg" }; /// /// The timer lock @@ -322,8 +322,16 @@ namespace MediaBrowser.Server.Implementations.IO /// The instance containing the event data. void watcher_Changed(object sender, FileSystemEventArgs e) { + var name = e.Name; + + // Ignore certain files + if (_alwaysIgnoreFiles.Contains(name, StringComparer.OrdinalIgnoreCase)) + { + return; + } + // Ignore when someone manually creates a new folder - if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder") + if (e.ChangeType == WatcherChangeTypes.Created && name == "New folder") { return; } @@ -339,12 +347,6 @@ namespace MediaBrowser.Server.Implementations.IO } } - // Ignore certain files - if (_alwaysIgnoreFiles.Any(f => e.Name.EndsWith(f, StringComparison.OrdinalIgnoreCase))) - { - return; - } - if (tempIgnorePaths.Contains(e.FullPath, StringComparer.OrdinalIgnoreCase)) { Logger.Debug("Watcher requested to ignore change to " + e.FullPath);