فهرست منبع

better comparison of names in directory watchers

Luke Pulverenti 12 سال پیش
والد
کامیت
7ceb377cde
1فایلهای تغییر یافته به همراه10 افزوده شده و 8 حذف شده
  1. 10 8
      MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs

+ 10 - 8
MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs

@@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.IO
         /// <summary>
         /// Any file name ending in any of these will be ignored by the watchers
         /// </summary>
-        private readonly List<string> _alwaysIgnoreFiles = new List<string> { "thumbs.db", "small.jpg", "albumart.jpg" };
+        private readonly IReadOnlyList<string> _alwaysIgnoreFiles = new List<string> { "thumbs.db", "small.jpg", "albumart.jpg" };
 
         /// <summary>
         /// The timer lock
@@ -322,8 +322,16 @@ namespace MediaBrowser.Server.Implementations.IO
         /// <param name="e">The <see cref="FileSystemEventArgs" /> instance containing the event data.</param>
         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);