mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
fixes #223 - New Content Localhost Popups Repeat 'Old' 'New Content' on Media Changes
This commit is contained in:
@@ -103,7 +103,8 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
LibraryManager.LibraryChanged += Instance_LibraryChanged;
|
||||
LibraryManager.ItemAdded += LibraryManager_ItemAdded;
|
||||
LibraryManager.ItemRemoved += LibraryManager_ItemRemoved;
|
||||
|
||||
var pathsToWatch = new List<string> { LibraryManager.RootFolder.Path };
|
||||
|
||||
@@ -137,6 +138,32 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemRemoved event of the LibraryManager control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
|
||||
void LibraryManager_ItemRemoved(object sender, ItemChangeEventArgs e)
|
||||
{
|
||||
if (e.Item.Parent is AggregateFolder)
|
||||
{
|
||||
StopWatchingPath(e.Item.Path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemAdded event of the LibraryManager control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
|
||||
void LibraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
|
||||
{
|
||||
if (e.Item.Parent is AggregateFolder)
|
||||
{
|
||||
StartWatchingPath(e.Item.Path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Examine a list of strings assumed to be file paths to see if it contains a parent of
|
||||
/// the provided path.
|
||||
@@ -231,32 +258,6 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
_fileSystemWatchers = new ConcurrentBag<FileSystemWatcher>(watchers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the LibraryChanged event of the Kernel
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MediaBrowser.Controller.Library.ChildrenChangedEventArgs" /> instance containing the event data.</param>
|
||||
void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e)
|
||||
{
|
||||
if (e.Folder is AggregateFolder && e.HasAddOrRemoveChange)
|
||||
{
|
||||
if (e.ItemsRemoved != null)
|
||||
{
|
||||
foreach (var item in e.ItemsRemoved.OfType<Folder>())
|
||||
{
|
||||
StopWatchingPath(item.Path);
|
||||
}
|
||||
}
|
||||
if (e.ItemsAdded != null)
|
||||
{
|
||||
foreach (var item in e.ItemsAdded.OfType<Folder>())
|
||||
{
|
||||
StartWatchingPath(item.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Error event of the watcher control.
|
||||
/// </summary>
|
||||
@@ -497,7 +498,8 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
LibraryManager.LibraryChanged -= Instance_LibraryChanged;
|
||||
LibraryManager.ItemAdded -= LibraryManager_ItemAdded;
|
||||
LibraryManager.ItemRemoved -= LibraryManager_ItemRemoved;
|
||||
|
||||
FileSystemWatcher watcher;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user