better comparison of names in directory watchers

This commit is contained in:
Luke Pulverenti 2013-06-09 09:31:37 -04:00
parent fb4c559549
commit 7ceb377cde

View File

@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.IO
/// <summary> /// <summary>
/// Any file name ending in any of these will be ignored by the watchers /// Any file name ending in any of these will be ignored by the watchers
/// </summary> /// </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> /// <summary>
/// The timer lock /// 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> /// <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)
{ {
var name = e.Name;
// Ignore certain files
if (_alwaysIgnoreFiles.Contains(name, StringComparer.OrdinalIgnoreCase))
{
return;
}
// Ignore when someone manually creates a new folder // 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; 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)) if (tempIgnorePaths.Contains(e.FullPath, StringComparer.OrdinalIgnoreCase))
{ {
Logger.Debug("Watcher requested to ignore change to " + e.FullPath); Logger.Debug("Watcher requested to ignore change to " + e.FullPath);