From 6481688d2acc23b789dab6e8ad04a96e48c46064 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 3 May 2013 00:10:11 -0400 Subject: fixes #223 - New Content Localhost Popups Repeat 'Old' 'New Content' on Media Changes --- .../Library/LibraryManager.cs | 89 ++++++++++++++-------- 1 file changed, 57 insertions(+), 32 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs') diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b78aa88f3..045b49aef 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -69,24 +69,20 @@ namespace MediaBrowser.Server.Implementations.Library /// The item repository. public IItemRepository ItemRepository { get; set; } - #region LibraryChanged Event /// - /// Fires whenever any validation routine adds or removes items. The added and removed items are properties of the args. - /// *** Will fire asynchronously. *** + /// Occurs when [item added]. /// - public event EventHandler LibraryChanged; + public event EventHandler ItemAdded; /// - /// Reports the library changed. + /// Occurs when [item updated]. /// - /// The instance containing the event data. - public void ReportLibraryChanged(ChildrenChangedEventArgs args) - { - UpdateLibraryCache(args); + public event EventHandler ItemUpdated; - EventHelper.FireEventIfNotNull(LibraryChanged, this, args, _logger); - } - #endregion + /// + /// Occurs when [item removed]. + /// + public event EventHandler ItemRemoved; /// /// The _logger @@ -302,25 +298,6 @@ namespace MediaBrowser.Server.Implementations.Library return new ConcurrentDictionary(items.ToDictionary(i => i.Id)); } - /// - /// Updates the library cache. - /// - /// The instance containing the event data. - private void UpdateLibraryCache(ChildrenChangedEventArgs args) - { - UpdateItemInLibraryCache(args.Folder); - - foreach (var item in args.ItemsAdded) - { - UpdateItemInLibraryCache(item); - } - - foreach (var item in args.ItemsUpdated) - { - UpdateItemInLibraryCache(item); - } - } - /// /// Updates the item in library cache. /// @@ -1069,13 +1046,61 @@ namespace MediaBrowser.Server.Implementations.Library return comparer; } + /// + /// Creates the item. + /// + /// The item. + /// The cancellation token. + /// Task. + public async Task CreateItem(BaseItem item, CancellationToken cancellationToken) + { + await SaveItem(item, cancellationToken).ConfigureAwait(false); + + UpdateItemInLibraryCache(item); + + if (ItemAdded != null) + { + ItemAdded(this, new ItemChangeEventArgs { Item = item }); + } + } + + /// + /// Updates the item. + /// + /// The item. + /// The cancellation token. + /// Task. + public async Task UpdateItem(BaseItem item, CancellationToken cancellationToken) + { + await SaveItem(item, cancellationToken).ConfigureAwait(false); + + UpdateItemInLibraryCache(item); + + if (ItemUpdated != null) + { + ItemUpdated(this, new ItemChangeEventArgs { Item = item }); + } + } + + /// + /// Reports the item removed. + /// + /// The item. + public void ReportItemRemoved(BaseItem item) + { + if (ItemRemoved != null) + { + ItemRemoved(this, new ItemChangeEventArgs { Item = item }); + } + } + /// /// Saves the item. /// /// The item. /// The cancellation token. /// Task. - public Task SaveItem(BaseItem item, CancellationToken cancellationToken) + private Task SaveItem(BaseItem item, CancellationToken cancellationToken) { return ItemRepository.SaveItem(item, cancellationToken); } -- cgit v1.2.3 From 9fdf5d1c4b488fe53e557870cacdf02b1b7fd4a2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 3 May 2013 00:32:16 -0400 Subject: updated nuget --- MediaBrowser.Controller/Entities/Folder.cs | 2 +- MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 3 +-- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs') diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 32fca66ca..bd2fa742e 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -436,7 +436,7 @@ namespace MediaBrowser.Controller.Entities /// /// The children. [IgnoreDataMember] - public IEnumerable Children + public ConcurrentBag Children { get { diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 045b49aef..90b7850fb 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.Configuration; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 982152b47..051914d00 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.87 + 3.0.89 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 632957113..6f7516e3a 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.87 + 3.0.89 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 11df1743b..f29863f7c 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.87 + 3.0.89 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3