From 5a3c46fd5e6fb1435d4d19db6b6624b061ff101a Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 13 Apr 2013 17:45:29 -0400 Subject: [PATCH] Have DirectoryWatchers ignore some files --- .../IO/DirectoryWatchers.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs index c33975a649..684b72cc94 100644 --- a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs @@ -38,6 +38,11 @@ namespace MediaBrowser.Server.Implementations.IO /// private readonly ConcurrentDictionary _tempIgnoredPaths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + /// + /// 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"}; + /// /// The timer lock /// @@ -313,10 +318,18 @@ namespace MediaBrowser.Server.Implementations.IO /// The instance containing the event data. void watcher_Changed(object sender, FileSystemEventArgs e) { + // Ignore when someone manually creates a new folder if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder") { return; } + + // Ignore certain files + if (_alwaysIgnoreFiles.Any(f => e.Name.EndsWith(f, StringComparison.OrdinalIgnoreCase))) + { + return; + } + if (_tempIgnoredPaths.ContainsKey(e.FullPath)) { Logger.Info("Watcher requested to ignore change to " + e.FullPath);