diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-05-22 09:09:44 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-05-22 09:09:44 -0400 |
| commit | 07802a5b6d9abf7f67376e05c5bdaa96a0ac9337 (patch) | |
| tree | 02b7c251fd5f3e0b2b1f3fb4995ca5c0a1ceda3b /MediaBrowser.Server.Implementations | |
| parent | 212e696f7e76c37b8134acf87f7354baabcb63d4 (diff) | |
| parent | 07b7ab9a0b64d51646addc9a2a75189c2981a854 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Server.Implementations')
4 files changed, 56 insertions, 53 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 2068ac0da..72cf42c14 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library public class LibraryManager : ILibraryManager { private IEnumerable<ILibraryPrescanTask> PrescanTasks { get; set; } - + /// <summary> /// Gets the intro providers. /// </summary> @@ -306,7 +306,20 @@ namespace MediaBrowser.Server.Implementations.Library /// <returns>BaseItem.</returns> public BaseItem ResolveItem(ItemResolveArgs args) { - var item = EntityResolvers.Select(r => r.ResolvePath(args)).FirstOrDefault(i => i != null); + var item = EntityResolvers.Select(r => + { + try + { + return r.ResolvePath(args); + } + catch (Exception ex) + { + _logger.ErrorException("Error in {0} resolving {1}", ex, r.GetType().Name, args.Path); + + return null; + } + + }).FirstOrDefault(i => i != null); if (item != null) { @@ -1028,7 +1041,7 @@ namespace MediaBrowser.Server.Implementations.Library await SaveItem(item, cancellationToken).ConfigureAwait(false); UpdateItemInLibraryCache(item); - + if (ItemAdded != null) { try diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 2b85268cc..1069f6ef1 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -98,11 +97,6 @@ namespace MediaBrowser.Server.Implementations.Providers } /// <summary> - /// The _supported providers key - /// </summary> - private readonly Guid _supportedProvidersKey = "SupportedProviders".GetMD5(); - - /// <summary> /// Runs all metadata providers for an entity, and returns true or false indicating if at least one was refreshed and requires persistence /// </summary> /// <param name="item">The item.</param> @@ -120,40 +114,10 @@ namespace MediaBrowser.Server.Implementations.Providers cancellationToken.ThrowIfCancellationRequested(); - // Determine if supported providers have changed - var supportedProviders = MetadataProviders.Where(p => p.Supports(item)).ToList(); - - BaseProviderInfo supportedProvidersInfo; - - var supportedProvidersValue = string.Join(string.Empty, supportedProviders.Select(i => i.GetType().Name)); - var providersChanged = false; - - item.ProviderData.TryGetValue(_supportedProvidersKey, out supportedProvidersInfo); - - var supportedProvidersHash = supportedProvidersValue.GetMD5(); - - if (supportedProvidersInfo != null) - { - // Force refresh if the supported providers have changed - providersChanged = force = force || supportedProvidersHash != supportedProvidersInfo.Data; - - // If providers have changed, clear provider info and update the supported providers hash - if (providersChanged) - { - _logger.Debug("Providers changed for {0}. Clearing and forcing refresh.", item.Name); - item.ProviderData.Clear(); - } - } - - if (providersChanged) - { - supportedProvidersInfo.Data = supportedProvidersHash; - } - if (force) item.ClearMetaValues(); // Run the normal providers sequentially in order of priority - foreach (var provider in supportedProviders) + foreach (var provider in MetadataProviders.Where(p => p.Supports(item))) { cancellationToken.ThrowIfCancellationRequested(); @@ -206,12 +170,7 @@ namespace MediaBrowser.Server.Implementations.Providers result |= results.Contains(true); } - if (providersChanged) - { - item.ProviderData[_supportedProvidersKey] = supportedProvidersInfo; - } - - return result || providersChanged; + return result; } /// <summary> diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index a45804f69..f8e47434e 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -36,6 +36,14 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// The web socket connections /// </summary> private readonly List<IWebSocketConnection> _webSocketConnections = new List<IWebSocketConnection>(); + /// <summary> + /// Gets the web socket connections. + /// </summary> + /// <value>The web socket connections.</value> + public IEnumerable<IWebSocketConnection> WebSocketConnections + { + get { return _webSocketConnections; } + } /// <summary> /// Gets or sets the external web socket server. @@ -83,6 +91,9 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// <value>The web socket listeners.</value> private readonly List<IWebSocketListener> _webSocketListeners = new List<IWebSocketListener>(); + /// <summary> + /// The _kernel + /// </summary> private readonly Kernel _kernel; /// <summary> @@ -240,7 +251,26 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> /// <exception cref="System.ArgumentNullException">messageType</exception> - public async Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, CancellationToken cancellationToken) + public Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, CancellationToken cancellationToken) + { + return SendWebSocketMessageAsync(messageType, dataFunction, _webSocketConnections, cancellationToken); + } + + /// <summary> + /// Sends the web socket message async. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="messageType">Type of the message.</param> + /// <param name="dataFunction">The data function.</param> + /// <param name="connections">The connections.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + /// <exception cref="System.ArgumentNullException">messageType + /// or + /// dataFunction + /// or + /// cancellationToken</exception> + public async Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, IEnumerable<IWebSocketConnection> connections, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(messageType)) { @@ -259,16 +289,16 @@ namespace MediaBrowser.Server.Implementations.ServerManager cancellationToken.ThrowIfCancellationRequested(); - var connections = _webSocketConnections.Where(s => s.State == WebSocketState.Open).ToList(); + var connectionsList = connections.Where(s => s.State == WebSocketState.Open).ToList(); - if (connections.Count > 0) + if (connectionsList.Count > 0) { _logger.Info("Sending web socket message {0}", messageType); var message = new WebSocketMessage<T> { MessageType = messageType, Data = dataFunction() }; var bytes = _jsonSerializer.SerializeToBytes(message); - var tasks = connections.Select(s => Task.Run(() => + var tasks = connectionsList.Select(s => Task.Run(() => { try { diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs index 19d177a94..44e833c7a 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs @@ -82,8 +82,9 @@ namespace MediaBrowser.Server.Implementations.Session var vals = message.Data.Split('|'); session.NowViewingItemType = vals[0]; - session.NowViewingItemIdentifier = vals[1]; - session.NowViewingContext = vals.Length > 2 ? vals[2] : null; + session.NowViewingItemId = vals[1]; + session.NowViewingItemName = vals[2]; + session.NowViewingContext = vals.Length > 3 ? vals[3] : null; } } else if (string.Equals(message.MessageType, "PlaybackStart", StringComparison.OrdinalIgnoreCase)) |
