Simplify/remove/clean code
* Remove useless runtime check (we only support one) * Remove unused args * Remove a global constant And ofc fix some warnings ;)
This commit is contained in:
parent
5024c52c60
commit
b44a70ff36
|
@ -200,7 +200,7 @@ namespace Emby.Server.Implementations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The disposable parts
|
/// The disposable parts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
private readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the configuration manager.
|
/// Gets the configuration manager.
|
||||||
|
@ -216,8 +216,9 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
#if BETA
|
#if BETA
|
||||||
return PackageVersionClass.Beta;
|
return PackageVersionClass.Beta;
|
||||||
#endif
|
#else
|
||||||
return PackageVersionClass.Release;
|
return PackageVersionClass.Release;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +341,6 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
protected IProcessFactory ProcessFactory { get; private set; }
|
protected IProcessFactory ProcessFactory { get; private set; }
|
||||||
|
|
||||||
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
|
|
||||||
protected readonly IXmlSerializer XmlSerializer;
|
protected readonly IXmlSerializer XmlSerializer;
|
||||||
|
|
||||||
protected ISocketFactory SocketFactory { get; private set; }
|
protected ISocketFactory SocketFactory { get; private set; }
|
||||||
|
@ -369,9 +369,6 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
|
|
||||||
// hack alert, until common can target .net core
|
|
||||||
BaseExtensions.CryptographyProvider = CryptographyProvider;
|
|
||||||
|
|
||||||
XmlSerializer = new MyXmlSerializer(fileSystem, loggerFactory);
|
XmlSerializer = new MyXmlSerializer(fileSystem, loggerFactory);
|
||||||
|
|
||||||
NetworkManager = networkManager;
|
NetworkManager = networkManager;
|
||||||
|
@ -735,13 +732,12 @@ namespace Emby.Server.Implementations
|
||||||
ApplicationHost.StreamHelper = new StreamHelper();
|
ApplicationHost.StreamHelper = new StreamHelper();
|
||||||
serviceCollection.AddSingleton(StreamHelper);
|
serviceCollection.AddSingleton(StreamHelper);
|
||||||
|
|
||||||
serviceCollection.AddSingleton(CryptographyProvider);
|
serviceCollection.AddSingleton(typeof(ICryptoProvider), typeof(CryptographyProvider));
|
||||||
|
|
||||||
SocketFactory = new SocketFactory();
|
SocketFactory = new SocketFactory();
|
||||||
serviceCollection.AddSingleton(SocketFactory);
|
serviceCollection.AddSingleton(SocketFactory);
|
||||||
|
|
||||||
InstallationManager = new InstallationManager(LoggerFactory, this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, ZipClient, PackageRuntime);
|
serviceCollection.AddSingleton(typeof(IInstallationManager), typeof(InstallationManager));
|
||||||
serviceCollection.AddSingleton(InstallationManager);
|
|
||||||
|
|
||||||
ZipClient = new ZipClient();
|
ZipClient = new ZipClient();
|
||||||
serviceCollection.AddSingleton(ZipClient);
|
serviceCollection.AddSingleton(ZipClient);
|
||||||
|
@ -908,8 +904,6 @@ namespace Emby.Server.Implementations
|
||||||
_serviceProvider = serviceCollection.BuildServiceProvider();
|
_serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string PackageRuntime => "netcore";
|
|
||||||
|
|
||||||
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
// Distinct these to prevent users from reporting problems that aren't actually problems
|
// Distinct these to prevent users from reporting problems that aren't actually problems
|
||||||
|
@ -1049,6 +1043,8 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void FindParts()
|
protected void FindParts()
|
||||||
{
|
{
|
||||||
|
InstallationManager = _serviceProvider.GetService<IInstallationManager>();
|
||||||
|
|
||||||
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
|
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
|
||||||
{
|
{
|
||||||
ServerConfigurationManager.Configuration.IsPortAuthorized = true;
|
ServerConfigurationManager.Configuration.IsPortAuthorized = true;
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Linq;
|
|
||||||
using MediaBrowser.Model.Cryptography;
|
using MediaBrowser.Model.Cryptography;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Cryptography
|
namespace Emby.Server.Implementations.Cryptography
|
||||||
|
@ -136,7 +135,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
{
|
{
|
||||||
return PBKDF2(DefaultHashMethod, bytes, salt, _defaultIterations);
|
return PBKDF2(DefaultHashMethod, bytes, salt, _defaultIterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] ComputeHash(PasswordHash hash)
|
public byte[] ComputeHash(PasswordHash hash)
|
||||||
{
|
{
|
||||||
int iterations = _defaultIterations;
|
int iterations = _defaultIterations;
|
||||||
|
|
|
@ -90,9 +90,10 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(displayPreferences));
|
throw new ArgumentNullException(nameof(displayPreferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(displayPreferences.Id))
|
if (string.IsNullOrEmpty(displayPreferences.Id))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(displayPreferences.Id));
|
throw new ArgumentException("Display preferences has an invalid Id", nameof(displayPreferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
|
@ -388,7 +388,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(),
|
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(),
|
||||||
|
|
||||||
CollectionFolders = GetTopParentIds(newAndRemoved, user, allUserRootChildren).ToArray()
|
CollectionFolders = GetTopParentIds(newAndRemoved, allUserRootChildren).ToArray()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
return item.SourceType == SourceType.Library;
|
return item.SourceType == SourceType.Library;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetTopParentIds(List<BaseItem> items, User user, List<Folder> allUserRootChildren)
|
private IEnumerable<string> GetTopParentIds(List<BaseItem> items, List<Folder> allUserRootChildren)
|
||||||
{
|
{
|
||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
// This code is executed before the service
|
// This code is executed before the service
|
||||||
var auth = AuthorizationContext.GetAuthorizationInfo(request);
|
var auth = AuthorizationContext.GetAuthorizationInfo(request);
|
||||||
|
|
||||||
if (!IsExemptFromAuthenticationToken(auth, authAttribtues, request))
|
if (!IsExemptFromAuthenticationToken(authAttribtues, request))
|
||||||
{
|
{
|
||||||
ValidateSecurityToken(request, auth.Token);
|
ValidateSecurityToken(request, auth.Token);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsExemptFromAuthenticationToken(AuthorizationInfo auth, IAuthenticationAttributes authAttribtues, IRequest request)
|
private bool IsExemptFromAuthenticationToken(IAuthenticationAttributes authAttribtues, IRequest request)
|
||||||
{
|
{
|
||||||
if (!_config.Configuration.IsStartupWizardCompleted && authAttribtues.AllowBeforeStartupWizard)
|
if (!_config.Configuration.IsStartupWizardCompleted && authAttribtues.AllowBeforeStartupWizard)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -14,8 +13,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StreamWriter : IAsyncStreamWriter, IHasHeaders
|
public class StreamWriter : IAsyncStreamWriter, IHasHeaders
|
||||||
{
|
{
|
||||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the source stream.
|
/// Gets or sets the source stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
public string HomePageUrl => "https://github.com/jellyfin/jellyfin";
|
public string HomePageUrl => "https://github.com/jellyfin/jellyfin";
|
||||||
|
|
||||||
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
|
public async Task RefreshSeriesTimers(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var seriesTimers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
|
var seriesTimers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RefreshTimers(CancellationToken cancellationToken, IProgress<double> progress)
|
public async Task RefreshTimers(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
|
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
|
@ -1087,8 +1087,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
|
|
||||||
if (coreService != null)
|
if (coreService != null)
|
||||||
{
|
{
|
||||||
await coreService.RefreshSeriesTimers(cancellationToken, new SimpleProgress<double>()).ConfigureAwait(false);
|
await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false);
|
||||||
await coreService.RefreshTimers(cancellationToken, new SimpleProgress<double>()).ConfigureAwait(false);
|
await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load these now which will prefetch metadata
|
// Load these now which will prefetch metadata
|
||||||
|
|
|
@ -10,14 +10,12 @@ using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.System;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
||||||
|
@ -52,9 +50,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
{
|
{
|
||||||
var channelIdPrefix = GetFullChannelIdPrefix(info);
|
var channelIdPrefix = GetFullChannelIdPrefix(info);
|
||||||
|
|
||||||
var result = await new M3uParser(Logger, _httpClient, _appHost).Parse(info.Url, channelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
|
return await new M3uParser(Logger, _httpClient, _appHost).Parse(info.Url, channelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return result.Cast<ChannelInfo>().ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
|
public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
|
||||||
|
@ -73,7 +69,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
return Task.FromResult(list);
|
return Task.FromResult(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] _disallowedSharedStreamExtensions = new string[]
|
private static readonly string[] _disallowedSharedStreamExtensions = new string[]
|
||||||
{
|
{
|
||||||
".mkv",
|
".mkv",
|
||||||
".mp4",
|
".mp4",
|
||||||
|
@ -88,9 +84,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
if (tunerCount > 0)
|
if (tunerCount > 0)
|
||||||
{
|
{
|
||||||
var tunerHostId = info.Id;
|
var tunerHostId = info.Id;
|
||||||
var liveStreams = currentLiveStreams.Where(i => string.Equals(i.TunerHostId, tunerHostId, StringComparison.OrdinalIgnoreCase)).ToList();
|
var liveStreams = currentLiveStreams.Where(i => string.Equals(i.TunerHostId, tunerHostId, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (liveStreams.Count >= tunerCount)
|
if (liveStreams.Count() >= tunerCount)
|
||||||
{
|
{
|
||||||
throw new LiveTvConflictException("M3U simultaneous stream limit has been reached.");
|
throw new LiveTvConflictException("M3U simultaneous stream limit has been reached.");
|
||||||
}
|
}
|
||||||
|
@ -98,7 +94,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
var sources = await GetChannelStreamMediaSources(info, channelInfo, cancellationToken).ConfigureAwait(false);
|
var sources = await GetChannelStreamMediaSources(info, channelInfo, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var mediaSource = sources.First();
|
var mediaSource = sources[0];
|
||||||
|
|
||||||
if (mediaSource.Protocol == MediaProtocol.Http && !mediaSource.RequiresLooping)
|
if (mediaSource.Protocol == MediaProtocol.Http && !mediaSource.RequiresLooping)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,6 @@ using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
@ -62,12 +61,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
return Task.FromResult((Stream)File.OpenRead(url));
|
return Task.FromResult((Stream)File.OpenRead(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
const string ExtInfPrefix = "#EXTINF:";
|
private const string ExtInfPrefix = "#EXTINF:";
|
||||||
|
|
||||||
private List<ChannelInfo> GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId)
|
private List<ChannelInfo> GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId)
|
||||||
{
|
{
|
||||||
var channels = new List<ChannelInfo>();
|
var channels = new List<ChannelInfo>();
|
||||||
string line;
|
string line;
|
||||||
string extInf = "";
|
string extInf = string.Empty;
|
||||||
|
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
channel.Path = line;
|
channel.Path = line;
|
||||||
channels.Add(channel);
|
channels.Add(channel);
|
||||||
extInf = "";
|
extInf = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +110,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl)
|
private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl)
|
||||||
{
|
{
|
||||||
var channel = new ChannelInfo();
|
var channel = new ChannelInfo()
|
||||||
channel.TunerHostId = tunerHostId;
|
{
|
||||||
|
TunerHostId = tunerHostId
|
||||||
|
};
|
||||||
|
|
||||||
extInf = extInf.Trim();
|
extInf = extInf.Trim();
|
||||||
|
|
||||||
|
@ -137,13 +139,15 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
{
|
{
|
||||||
channelIdValues.Add(channelId);
|
channelIdValues.Add(channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(tvgId))
|
if (!string.IsNullOrWhiteSpace(tvgId))
|
||||||
{
|
{
|
||||||
channelIdValues.Add(tvgId);
|
channelIdValues.Add(tvgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelIdValues.Count > 0)
|
if (channelIdValues.Count > 0)
|
||||||
{
|
{
|
||||||
channel.Id = string.Join("_", channelIdValues.ToArray());
|
channel.Id = string.Join("_", channelIdValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
|
@ -152,7 +156,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
private string GetChannelNumber(string extInf, Dictionary<string, string> attributes, string mediaUrl)
|
private string GetChannelNumber(string extInf, Dictionary<string, string> attributes, string mediaUrl)
|
||||||
{
|
{
|
||||||
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
|
var nameInExtInf = nameParts.Length > 1 ? nameParts[nameParts.Length - 1].Trim() : null;
|
||||||
|
|
||||||
string numberString = null;
|
string numberString = null;
|
||||||
string attributeValue;
|
string attributeValue;
|
||||||
|
|
|
@ -12,7 +12,6 @@ using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Progress;
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Model.Cryptography;
|
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
@ -39,11 +38,10 @@ namespace Emby.Server.Implementations.Updates
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The completed installations
|
/// The completed installations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ConcurrentBag<InstallationInfo> CompletedInstallationsInternal { get; set; }
|
private ConcurrentBag<InstallationInfo> _completedInstallationsInternal;
|
||||||
|
|
||||||
public IEnumerable<InstallationInfo> CompletedInstallations => CompletedInstallationsInternal;
|
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
|
||||||
|
|
||||||
#region PluginUninstalled Event
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [plugin uninstalled].
|
/// Occurs when [plugin uninstalled].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -57,9 +55,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
{
|
{
|
||||||
PluginUninstalled?.Invoke(this, new GenericEventArgs<IPlugin> { Argument = plugin });
|
PluginUninstalled?.Invoke(this, new GenericEventArgs<IPlugin> { Argument = plugin });
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region PluginUpdated Event
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [plugin updated].
|
/// Occurs when [plugin updated].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -77,9 +73,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
|
|
||||||
_applicationHost.NotifyPendingRestart();
|
_applicationHost.NotifyPendingRestart();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region PluginInstalled Event
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [plugin updated].
|
/// Occurs when [plugin updated].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,7 +90,6 @@ namespace Emby.Server.Implementations.Updates
|
||||||
|
|
||||||
_applicationHost.NotifyPendingRestart();
|
_applicationHost.NotifyPendingRestart();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _logger
|
/// The _logger
|
||||||
|
@ -115,12 +108,8 @@ namespace Emby.Server.Implementations.Updates
|
||||||
/// <value>The application host.</value>
|
/// <value>The application host.</value>
|
||||||
private readonly IApplicationHost _applicationHost;
|
private readonly IApplicationHost _applicationHost;
|
||||||
|
|
||||||
private readonly ICryptoProvider _cryptographyProvider;
|
|
||||||
private readonly IZipClient _zipClient;
|
private readonly IZipClient _zipClient;
|
||||||
|
|
||||||
// netframework or netcore
|
|
||||||
private readonly string _packageRuntime;
|
|
||||||
|
|
||||||
public InstallationManager(
|
public InstallationManager(
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IApplicationHost appHost,
|
IApplicationHost appHost,
|
||||||
|
@ -129,9 +118,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
ICryptoProvider cryptographyProvider,
|
IZipClient zipClient)
|
||||||
IZipClient zipClient,
|
|
||||||
string packageRuntime)
|
|
||||||
{
|
{
|
||||||
if (loggerFactory == null)
|
if (loggerFactory == null)
|
||||||
{
|
{
|
||||||
|
@ -139,18 +126,16 @@ namespace Emby.Server.Implementations.Updates
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentInstallations = new List<Tuple<InstallationInfo, CancellationTokenSource>>();
|
CurrentInstallations = new List<Tuple<InstallationInfo, CancellationTokenSource>>();
|
||||||
CompletedInstallationsInternal = new ConcurrentBag<InstallationInfo>();
|
_completedInstallationsInternal = new ConcurrentBag<InstallationInfo>();
|
||||||
|
|
||||||
|
_logger = loggerFactory.CreateLogger(nameof(InstallationManager));
|
||||||
_applicationHost = appHost;
|
_applicationHost = appHost;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_config = config;
|
_config = config;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_cryptographyProvider = cryptographyProvider;
|
|
||||||
_zipClient = zipClient;
|
_zipClient = zipClient;
|
||||||
_packageRuntime = packageRuntime;
|
|
||||||
_logger = loggerFactory.CreateLogger(nameof(InstallationManager));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Version GetPackageVersion(PackageVersionInfo version)
|
private static Version GetPackageVersion(PackageVersionInfo version)
|
||||||
|
@ -222,11 +207,6 @@ namespace Emby.Server.Implementations.Updates
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(version.runtimes) || version.runtimes.IndexOf(_packageRuntime, StringComparison.OrdinalIgnoreCase) == -1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
versions.Add(version);
|
versions.Add(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +428,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
CurrentInstallations.Remove(tuple);
|
CurrentInstallations.Remove(tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletedInstallationsInternal.Add(installationInfo);
|
_completedInstallationsInternal.Add(installationInfo);
|
||||||
|
|
||||||
PackageInstallationCompleted?.Invoke(this, installationEventArgs);
|
PackageInstallationCompleted?.Invoke(this, installationEventArgs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using MediaBrowser.Model.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Extensions
|
namespace MediaBrowser.Common.Extensions
|
||||||
{
|
{
|
||||||
|
@ -9,8 +10,6 @@ namespace MediaBrowser.Common.Extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class BaseExtensions
|
public static class BaseExtensions
|
||||||
{
|
{
|
||||||
public static ICryptoProvider CryptographyProvider { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Strips the HTML.
|
/// Strips the HTML.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -31,7 +30,10 @@ namespace MediaBrowser.Common.Extensions
|
||||||
/// <returns>Guid.</returns>
|
/// <returns>Guid.</returns>
|
||||||
public static Guid GetMD5(this string str)
|
public static Guid GetMD5(this string str)
|
||||||
{
|
{
|
||||||
return CryptographyProvider.GetMD5(str);
|
using (var provider = MD5.Create())
|
||||||
|
{
|
||||||
|
return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
<Rule Id="SA1633" Action="None" />
|
<Rule Id="SA1633" Action="None" />
|
||||||
</Rules>
|
</Rules>
|
||||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design">
|
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design">
|
||||||
|
<!-- disable warning CA1822: Member does not access instance data and can be marked as static -->
|
||||||
|
<Rule Id="CA1822" Action="Info" />
|
||||||
|
|
||||||
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
|
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
|
||||||
<Rule Id="CA1054" Action="None" />
|
<Rule Id="CA1054" Action="None" />
|
||||||
</Rules>
|
</Rules>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user