Răsfoiți Sursa

Have DirectoryWatchers ignore some files

Eric Reed 12 ani în urmă
părinte
comite
5a3c46fd5e
1 a modificat fișierele cu 13 adăugiri și 0 ștergeri
  1. 13 0
      MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs

+ 13 - 0
MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs

@@ -38,6 +38,11 @@ namespace MediaBrowser.Server.Implementations.IO
         /// </summary>
         /// </summary>
         private readonly ConcurrentDictionary<string,string> _tempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
         private readonly ConcurrentDictionary<string,string> _tempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 
 
+        /// <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"}; 
+
         /// <summary>
         /// <summary>
         /// The timer lock
         /// The timer lock
         /// </summary>
         /// </summary>
@@ -313,10 +318,18 @@ namespace MediaBrowser.Server.Implementations.IO
         /// <param name="e">The <see cref="FileSystemEventArgs" /> instance containing the event data.</param>
         /// <param name="e">The <see cref="FileSystemEventArgs" /> instance containing the event data.</param>
         void watcher_Changed(object sender, FileSystemEventArgs e)
         void watcher_Changed(object sender, FileSystemEventArgs e)
         {
         {
+            // Ignore when someone manually creates a new folder
             if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder")
             if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder")
             {
             {
                 return;
                 return;
             }
             }
+
+            // Ignore certain files
+            if (_alwaysIgnoreFiles.Any(f => e.Name.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
+            {
+                return;
+            }
+
             if (_tempIgnoredPaths.ContainsKey(e.FullPath))
             if (_tempIgnoredPaths.ContainsKey(e.FullPath))
             {
             {
                 Logger.Info("Watcher requested to ignore change to " + e.FullPath);
                 Logger.Info("Watcher requested to ignore change to " + e.FullPath);