From 78e4e2ed929155b433fc0cbb2ea6fc7f64411a72 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sat, 2 Feb 2019 21:45:29 +0100 Subject: [PATCH] Fix all warnings --- Emby.Drawing/ImageProcessor.cs | 9 ----- .../Library/UserManager.cs | 34 +++++++++---------- .../LiveTv/EmbyTV/EmbyTV.cs | 1 - .../LiveTv/LiveTvManager.cs | 27 ++++++++------- .../LiveTv/ILiveTvService.cs | 5 --- 5 files changed, 31 insertions(+), 45 deletions(-) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index f229d9a0b4..097b4c40b7 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -261,15 +261,6 @@ namespace Emby.Drawing return (cacheFilePath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(cacheFilePath)); } - catch (ArgumentOutOfRangeException ex) - { - // Decoder failed to decode it -#if DEBUG - _logger.LogError(ex, "Error encoding image"); -#endif - // Just spit out the original file if all the options are default - return (originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); - } catch (Exception ex) { // If it fails for whatever reason, return the original image diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index b33ae72b70..215978341f 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -448,30 +448,30 @@ namespace Emby.Server.Implementations.Library private void UpdateInvalidLoginAttemptCount(User user, int newValue) { - if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0) + if (user.Policy.InvalidLoginAttemptCount == newValue || newValue <= 0) { - user.Policy.InvalidLoginAttemptCount = newValue; + return; + } - var maxCount = user.Policy.IsAdministrator ? 3 : 5; + user.Policy.InvalidLoginAttemptCount = newValue; - // TODO: Fix - /* - var fireLockout = false; + var maxCount = user.Policy.IsAdministrator ? 3 : 5; - if (newValue >= maxCount) - { - _logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture)); - user.Policy.IsDisabled = true; + var fireLockout = false; - fireLockout = true; - }*/ + if (newValue >= maxCount) + { + _logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue); + user.Policy.IsDisabled = true; - UpdateUserPolicy(user, user.Policy, false); + fireLockout = true; + } - /* if (fireLockout) - { - UserLockedOut?.Invoke(this, new GenericEventArgs(user)); - }*/ + UpdateUserPolicy(user, user.Policy, false); + + if (fireLockout) + { + UserLockedOut?.Invoke(this, new GenericEventArgs(user)); } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index bce9c240d5..c5c0ac4638 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -64,7 +64,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public static EmbyTV Current; - public event EventHandler DataSourceChanged; public event EventHandler> TimerCreated; public event EventHandler> TimerCancelled; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index c3437bcdaa..a363028760 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.LiveTv private readonly LiveTvDtoService _tvDtoService; - private ILiveTvService[] _services = new ILiveTvService[] { }; + private ILiveTvService[] _services = Array.Empty(); private ITunerHost[] _tunerHosts = Array.Empty(); private IListingsProvider[] _listingProviders = Array.Empty(); @@ -127,8 +127,6 @@ namespace Emby.Server.Implementations.LiveTv foreach (var service in _services) { - service.DataSourceChanged += service_DataSourceChanged; - if (service is EmbyTV.EmbyTV embyTv) { embyTv.TimerCreated += EmbyTv_TimerCreated; @@ -184,14 +182,6 @@ namespace Emby.Server.Implementations.LiveTv return EmbyTV.EmbyTV.Current.DiscoverTuners(newDevicesOnly, cancellationToken); } - void service_DataSourceChanged(object sender, EventArgs e) - { - if (!_isDisposed) - { - _taskManager.CancelIfRunningAndQueue(); - } - } - public QueryResult GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken) { var user = query.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(query.UserId); @@ -2153,17 +2143,28 @@ namespace Emby.Server.Implementations.LiveTv Dispose(true); } - private bool _isDisposed = false; + private bool _disposed = false; /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool dispose) { + if (_disposed) + { + return; + } + if (dispose) { - _isDisposed = true; + // TODO: Dispose stuff } + + _services = null; + _listingProviders = null; + _tunerHosts = null; + + _disposed = true; } private LiveTvServiceInfo[] GetServiceInfos() diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index ba3813d8a1..b71a766485 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -12,11 +12,6 @@ namespace MediaBrowser.Controller.LiveTv /// public interface ILiveTvService { - /// - /// Occurs when [data source changed]. - /// - event EventHandler DataSourceChanged; - /// /// Gets the name. ///