diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-07 17:42:29 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-07 17:42:29 -0400 |
| commit | b1859d41e861630a95357bf21bb46af6c4fb5686 (patch) | |
| tree | b6309083d34e9be8bea03cae82ca6b6e5b35d7eb /MediaBrowser.Server.Implementations | |
| parent | b82254060d2fa33ffb2fd87ba31196d61a4940af (diff) | |
update collection menus
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 34 insertions, 32 deletions
diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index ac27a0ab4..8a19ee431 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -172,30 +172,31 @@ namespace MediaBrowser.Server.Implementations.Collections itemList.Add(item); - if (currentLinkedChildren.Any(i => i.Id == itemId)) + if (currentLinkedChildren.All(i => i.Id != itemId)) { - throw new ArgumentException("Item already exists in collection"); + list.Add(LinkedChild.Create(item)); } - - list.Add(LinkedChild.Create(item)); } - collection.LinkedChildren.AddRange(list); + if (list.Count > 0) + { + collection.LinkedChildren.AddRange(list); - collection.UpdateRatingToContent(); + collection.UpdateRatingToContent(); - await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); - _providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(_fileSystem)); + _providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(_fileSystem)); - if (fireEvent) - { - EventHelper.FireEventIfNotNull(ItemsAddedToCollection, this, new CollectionModifiedEventArgs + if (fireEvent) { - Collection = collection, - ItemsChanged = itemList + EventHelper.FireEventIfNotNull(ItemsAddedToCollection, this, new CollectionModifiedEventArgs + { + Collection = collection, + ItemsChanged = itemList - }, _logger); + }, _logger); + } } } diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index 45b159574..a7d3854e7 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -16,7 +16,6 @@ using System; using System.IO; using System.Linq; using CommonIO; -using MediaBrowser.Common.IO; namespace MediaBrowser.Server.Implementations.Configuration { @@ -25,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.Configuration /// </summary> public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager { - private readonly IFileSystem _fileSystem; /// <summary> /// Initializes a new instance of the <see cref="ServerConfigurationManager" /> class. @@ -33,10 +31,10 @@ namespace MediaBrowser.Server.Implementations.Configuration /// <param name="applicationPaths">The application paths.</param> /// <param name="logManager">The log manager.</param> /// <param name="xmlSerializer">The XML serializer.</param> + /// <param name="fileSystem">The file system.</param> public ServerConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer, IFileSystem fileSystem) - : base(applicationPaths, logManager, xmlSerializer) + : base(applicationPaths, logManager, xmlSerializer, fileSystem) { - _fileSystem = fileSystem; UpdateItemsByNamePath(); UpdateMetadataPath(); } @@ -203,7 +201,7 @@ namespace MediaBrowser.Server.Implementations.Configuration && !string.Equals(Configuration.ItemsByNamePath ?? string.Empty, newPath)) { // Validate - if (!_fileSystem.DirectoryExists(newPath)) + if (!FileSystem.DirectoryExists(newPath)) { throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); } @@ -225,7 +223,7 @@ namespace MediaBrowser.Server.Implementations.Configuration && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath)) { // Validate - if (!_fileSystem.DirectoryExists(newPath)) + if (!FileSystem.DirectoryExists(newPath)) { throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); } @@ -234,14 +232,6 @@ namespace MediaBrowser.Server.Implementations.Configuration } } - private void EnsureWriteAccess(string path) - { - var file = Path.Combine(path, Guid.NewGuid().ToString()); - - _fileSystem.WriteAllText(file, string.Empty); - _fileSystem.DeleteFile(file); - } - public void DisableMetadataService(string service) { DisableMetadataService(typeof(Movie), Configuration, service); diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index c7e437931..9622afb97 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -49,14 +49,23 @@ namespace MediaBrowser.Server.Implementations.Connect private async void TimerCallback(object state) { + var index = 0; + foreach (var ipLookupUrl in _ipLookups) { try { + // Sometimes whatismyipaddress might fail, but it won't do us any good having users raise alarms over it. + var logErrors = index > 0; + +#if DEBUG + logErrors = true; +#endif using (var stream = await _httpClient.Get(new HttpRequestOptions { Url = ipLookupUrl, - UserAgent = "Emby Server/" + _appHost.ApplicationVersion + UserAgent = "Emby Server/" + _appHost.ApplicationVersion, + LogErrors = logErrors }).ConfigureAwait(false)) { @@ -80,6 +89,8 @@ namespace MediaBrowser.Server.Implementations.Connect { _logger.ErrorException("Error getting connection info", ex); } + + index++; } } @@ -94,8 +105,8 @@ namespace MediaBrowser.Server.Implementations.Connect try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - _fileSystem.WriteAllText(path, address, Encoding.UTF8); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.WriteAllText(path, address, Encoding.UTF8); } catch (Exception ex) { @@ -109,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.Connect try { - var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8); + var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8); if (IsValid(endpoint)) { |
