update collection menus
This commit is contained in:
parent
b82254060d
commit
b1859d41e8
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using CommonIO;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Implementations.Configuration
|
namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,7 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The application paths.</value>
|
/// <value>The application paths.</value>
|
||||||
public IApplicationPaths CommonApplicationPaths { get; private set; }
|
public IApplicationPaths CommonApplicationPaths { get; private set; }
|
||||||
|
public readonly IFileSystem FileSystem;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _configuration loaded
|
/// The _configuration loaded
|
||||||
|
@ -96,10 +98,11 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
/// <param name="applicationPaths">The application paths.</param>
|
/// <param name="applicationPaths">The application paths.</param>
|
||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
/// <param name="xmlSerializer">The XML serializer.</param>
|
||||||
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer)
|
protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
CommonApplicationPaths = applicationPaths;
|
CommonApplicationPaths = applicationPaths;
|
||||||
XmlSerializer = xmlSerializer;
|
XmlSerializer = xmlSerializer;
|
||||||
|
FileSystem = fileSystem;
|
||||||
Logger = logManager.GetLogger(GetType().Name);
|
Logger = logManager.GetLogger(GetType().Name);
|
||||||
|
|
||||||
UpdateCachePath();
|
UpdateCachePath();
|
||||||
|
@ -199,9 +202,19 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
{
|
{
|
||||||
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
|
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnsureWriteAccess(newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void EnsureWriteAccess(string path)
|
||||||
|
{
|
||||||
|
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
||||||
|
|
||||||
|
FileSystem.WriteAllText(file, string.Empty);
|
||||||
|
FileSystem.DeleteFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, object> _configurations = new ConcurrentDictionary<string, object>();
|
private readonly ConcurrentDictionary<string, object> _configurations = new ConcurrentDictionary<string, object>();
|
||||||
|
|
||||||
private string GetConfigurationFile(string key)
|
private string GetConfigurationFile(string key)
|
||||||
|
|
|
@ -465,7 +465,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException ex)
|
catch (OperationCanceledException ex)
|
||||||
{
|
{
|
||||||
var exception = GetCancellationException(options.Url, options.CancellationToken, ex);
|
var exception = GetCancellationException(options, options.CancellationToken, ex);
|
||||||
|
|
||||||
var httpException = exception as HttpException;
|
var httpException = exception as HttpException;
|
||||||
|
|
||||||
|
@ -496,8 +496,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||||
/// <param name="options">The options.</param>
|
/// <param name="options">The options.</param>
|
||||||
/// <returns>HttpException.</returns>
|
/// <returns>HttpException.</returns>
|
||||||
private HttpException GetException(WebException ex, HttpRequestOptions options)
|
private HttpException GetException(WebException ex, HttpRequestOptions options)
|
||||||
|
{
|
||||||
|
if (options.LogErrors)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||||
|
}
|
||||||
|
|
||||||
var exception = new HttpException(ex.Message, ex);
|
var exception = new HttpException(ex.Message, ex);
|
||||||
|
|
||||||
|
@ -710,10 +713,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||||
|
|
||||||
if (operationCanceledException != null)
|
if (operationCanceledException != null)
|
||||||
{
|
{
|
||||||
return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException);
|
return GetCancellationException(options, options.CancellationToken, operationCanceledException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.LogErrors)
|
||||||
|
{
|
||||||
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
_logger.ErrorException("Error getting response from " + options.Url, ex);
|
||||||
|
}
|
||||||
|
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
@ -785,18 +791,21 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Throws the cancellation exception.
|
/// Throws the cancellation exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url">The URL.</param>
|
/// <param name="options">The options.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="exception">The exception.</param>
|
/// <param name="exception">The exception.</param>
|
||||||
/// <returns>Exception.</returns>
|
/// <returns>Exception.</returns>
|
||||||
private Exception GetCancellationException(string url, CancellationToken cancellationToken, OperationCanceledException exception)
|
private Exception GetCancellationException(HttpRequestOptions options, CancellationToken cancellationToken, OperationCanceledException exception)
|
||||||
{
|
{
|
||||||
// If the HttpClient's timeout is reached, it will cancel the Task internally
|
// If the HttpClient's timeout is reached, it will cancel the Task internally
|
||||||
if (!cancellationToken.IsCancellationRequested)
|
if (!cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
var msg = string.Format("Connection to {0} timed out", url);
|
var msg = string.Format("Connection to {0} timed out", options.Url);
|
||||||
|
|
||||||
|
if (options.LogErrors)
|
||||||
|
{
|
||||||
_logger.Error(msg);
|
_logger.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
// Throw an HttpException so that the caller doesn't think it was cancelled by user code
|
// Throw an HttpException so that the caller doesn't think it was cancelled by user code
|
||||||
return new HttpException(msg, exception)
|
return new HttpException(msg, exception)
|
||||||
|
|
|
@ -87,6 +87,7 @@ namespace MediaBrowser.Common.Net
|
||||||
public bool BufferContent { get; set; }
|
public bool BufferContent { get; set; }
|
||||||
|
|
||||||
public bool LogRequest { get; set; }
|
public bool LogRequest { get; set; }
|
||||||
|
public bool LogErrors { get; set; }
|
||||||
|
|
||||||
public bool LogErrorResponseBody { get; set; }
|
public bool LogErrorResponseBody { get; set; }
|
||||||
public bool EnableKeepAlive { get; set; }
|
public bool EnableKeepAlive { get; set; }
|
||||||
|
@ -116,6 +117,7 @@ namespace MediaBrowser.Common.Net
|
||||||
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
LogRequest = true;
|
LogRequest = true;
|
||||||
|
LogErrors = true;
|
||||||
CacheMode = CacheMode.None;
|
CacheMode = CacheMode.None;
|
||||||
|
|
||||||
TimeoutMs = 20000;
|
TimeoutMs = 20000;
|
||||||
|
|
|
@ -172,14 +172,14 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||||
|
|
||||||
itemList.Add(item);
|
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));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list.Count > 0)
|
||||||
|
{
|
||||||
collection.LinkedChildren.AddRange(list);
|
collection.LinkedChildren.AddRange(list);
|
||||||
|
|
||||||
collection.UpdateRatingToContent();
|
collection.UpdateRatingToContent();
|
||||||
|
@ -198,6 +198,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||||
}, _logger);
|
}, _logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds)
|
public async Task RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,6 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Configuration
|
namespace MediaBrowser.Server.Implementations.Configuration
|
||||||
{
|
{
|
||||||
|
@ -25,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
|
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
|
||||||
{
|
{
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfigurationManager" /> class.
|
/// 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="applicationPaths">The application paths.</param>
|
||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
/// <param name="xmlSerializer">The XML serializer.</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)
|
public ServerConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
|
||||||
: base(applicationPaths, logManager, xmlSerializer)
|
: base(applicationPaths, logManager, xmlSerializer, fileSystem)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
|
||||||
UpdateItemsByNamePath();
|
UpdateItemsByNamePath();
|
||||||
UpdateMetadataPath();
|
UpdateMetadataPath();
|
||||||
}
|
}
|
||||||
|
@ -203,7 +201,7 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
||||||
&& !string.Equals(Configuration.ItemsByNamePath ?? string.Empty, newPath))
|
&& !string.Equals(Configuration.ItemsByNamePath ?? string.Empty, newPath))
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!_fileSystem.DirectoryExists(newPath))
|
if (!FileSystem.DirectoryExists(newPath))
|
||||||
{
|
{
|
||||||
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", 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))
|
&& !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath))
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!_fileSystem.DirectoryExists(newPath))
|
if (!FileSystem.DirectoryExists(newPath))
|
||||||
{
|
{
|
||||||
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", 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)
|
public void DisableMetadataService(string service)
|
||||||
{
|
{
|
||||||
DisableMetadataService(typeof(Movie), Configuration, service);
|
DisableMetadataService(typeof(Movie), Configuration, service);
|
||||||
|
|
|
@ -49,14 +49,23 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||||
|
|
||||||
private async void TimerCallback(object state)
|
private async void TimerCallback(object state)
|
||||||
{
|
{
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
foreach (var ipLookupUrl in _ipLookups)
|
foreach (var ipLookupUrl in _ipLookups)
|
||||||
{
|
{
|
||||||
try
|
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
|
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
||||||
{
|
{
|
||||||
Url = ipLookupUrl,
|
Url = ipLookupUrl,
|
||||||
UserAgent = "Emby Server/" + _appHost.ApplicationVersion
|
UserAgent = "Emby Server/" + _appHost.ApplicationVersion,
|
||||||
|
LogErrors = logErrors
|
||||||
|
|
||||||
}).ConfigureAwait(false))
|
}).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
@ -80,6 +89,8 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error getting connection info", ex);
|
_logger.ErrorException("Error getting connection info", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user