diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs index 704145dbb..036be785b 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/AvailabilitySpecification.cs @@ -7,12 +7,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { public class AvailabilitySpecification : IDecisionEngineSpecification { - private readonly IConfigService _settingsService; + private readonly IConfigService _configService; private readonly Logger _logger; - public AvailabilitySpecification(IConfigService settingsService, Logger logger) + public AvailabilitySpecification(IConfigService configService, Logger logger) { - _settingsService = settingsService; + _configService = configService; _logger = logger; } @@ -21,18 +21,17 @@ public AvailabilitySpecification(IConfigService settingsService, Logger logger) public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria) { - if (searchCriteria != null) + if (searchCriteria is { UserInvokedSearch: true }) { - if (searchCriteria.UserInvokedSearch) - { - _logger.Debug("Skipping availability check during search"); - return Decision.Accept(); - } + _logger.Debug("Skipping availability check during search"); + return Decision.Accept(); } - if (!subject.Movie.IsAvailable(_settingsService.AvailabilityDelay)) + var availabilityDelay = _configService.AvailabilityDelay; + + if (!subject.Movie.IsAvailable(availabilityDelay)) { - return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, _settingsService.AvailabilityDelay, subject.Movie.MinimumAvailability.ToString()); + return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, availabilityDelay, subject.Movie.MinimumAvailability.ToString()); } return Decision.Accept(); diff --git a/src/NzbDrone.Core/Movies/Movie.cs b/src/NzbDrone.Core/Movies/Movie.cs index ce9dd483b..1e4999ef7 100644 --- a/src/NzbDrone.Core/Movies/Movie.cs +++ b/src/NzbDrone.Core/Movies/Movie.cs @@ -81,7 +81,7 @@ public bool IsAvailable(int delay = 0) // This more complex sequence handles the delay DateTime minimumAvailabilityDate; - if ((MinimumAvailability == MovieStatusType.TBA) || (MinimumAvailability == MovieStatusType.Announced)) + if (MinimumAvailability is MovieStatusType.TBA or MovieStatusType.Announced) { minimumAvailabilityDate = DateTime.MinValue; } @@ -105,16 +105,16 @@ public bool IsAvailable(int delay = 0) } else { - minimumAvailabilityDate = MovieMetadata.Value.InCinemas.HasValue ? MovieMetadata.Value.InCinemas.Value.AddDays(90) : DateTime.MaxValue; + minimumAvailabilityDate = MovieMetadata.Value.InCinemas?.AddDays(90) ?? DateTime.MaxValue; } } if (minimumAvailabilityDate == DateTime.MinValue || minimumAvailabilityDate == DateTime.MaxValue) { - return DateTime.Now >= minimumAvailabilityDate; + return DateTime.UtcNow >= minimumAvailabilityDate; } - return DateTime.Now >= minimumAvailabilityDate.AddDays((double)delay); + return DateTime.UtcNow >= minimumAvailabilityDate.AddDays(delay); } public override string ToString()