Fixed: Simplify DateTime alteration

pull/1419/head
Bogdan 2 years ago
parent 5d09c2b5fa
commit 306209fcc2

@ -55,7 +55,7 @@ namespace NzbDrone.Core.HealthCheck
_startupHealthChecks = _healthChecks.Where(v => v.CheckOnStartup).ToArray();
_scheduledHealthChecks = _healthChecks.Where(v => v.CheckOnSchedule).ToArray();
_eventDrivenHealthChecks = GetEventDrivenHealthChecks();
_startupGracePeriodEndTime = runtimeInfo.StartTime + TimeSpan.FromMinutes(15);
_startupGracePeriodEndTime = runtimeInfo.StartTime.AddMinutes(15);
}
public List<HealthCheck> Results()

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Indexers.Definitions
if (response.Content != null && !CheckIfLoginNeeded(response))
{
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("Anidub authentication succeeded");
}
else

@ -71,7 +71,7 @@ namespace NzbDrone.Core.Indexers.Definitions
if (response.Content != null && response.Content.Contains("logout.php"))
{
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("AnimeTorrents authentication succeeded");
}

@ -80,7 +80,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Anthelion authentication succeeded.");
}

@ -87,7 +87,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("BB authentication succeeded.");
}

@ -100,7 +100,7 @@ namespace NzbDrone.Core.Indexers.Definitions
if (response.Content != null && response.Content.Contains("<a href=\"logout.php\">Logout</a>"))
{
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("BakaBT authentication succeeded");
}

@ -226,7 +226,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
CheckForError(response, login.Error);
CookiesUpdater(Cookies, DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(Cookies, DateTime.Now.AddDays(30));
}
else if (login.Method == "form")
{
@ -467,13 +467,13 @@ namespace NzbDrone.Core.Indexers.Cardigann
Cookies = loginResult.GetCookies();
CheckForError(loginResult, login.Error);
CookiesUpdater(Cookies, DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(Cookies, DateTime.Now.AddDays(30));
}
else if (login.Method == "cookie")
{
CookiesUpdater(null, null);
Settings.ExtraFieldData.TryGetValue("cookie", out var cookies);
CookiesUpdater(CookieUtil.CookieHeaderToDictionary((string)cookies), DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(CookieUtil.CookieHeaderToDictionary((string)cookies), DateTime.Now.AddDays(30));
}
else if (login.Method == "get")
{
@ -504,7 +504,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
CheckForError(response, login.Error);
CookiesUpdater(Cookies, DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(Cookies, DateTime.Now.AddDays(30));
}
else if (login.Method == "oneurl")
{
@ -529,7 +529,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
CheckForError(response, login.Error);
CookiesUpdater(Cookies, DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(Cookies, DateTime.Now.AddDays(30));
}
else
{

@ -78,7 +78,7 @@ public class FunFile : TorrentIndexerBase<UserPassTorrentBaseSettings>
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -56,7 +56,7 @@ public abstract class GazelleBase<TSettings> : TorrentIndexerBase<TSettings>
CheckForLoginError(response);
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Gazelle authentication succeeded.");
}

@ -84,7 +84,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("HDSpace authentication succeeded.");
}

@ -71,7 +71,7 @@ namespace NzbDrone.Core.Indexers.Definitions
var response = await ExecuteAuth(authLoginRequest);
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("HDTorrents authentication succeeded.");
}

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("ImmortalSeed authentication succeeded.");
}

@ -84,7 +84,7 @@ public class Libble : TorrentIndexerBase<LibbleSettings>
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -95,7 +95,7 @@ public class NorBits : TorrentIndexerBase<NorBitsSettings>
}
var cookies = loginResponse.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -66,7 +66,7 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
request.HttpRequest.Cookies[cookie.Key] = cookie.Value;
}
CookiesUpdater(Cookies, DateTime.Now + TimeSpan.FromDays(30));
CookiesUpdater(Cookies, DateTime.Now.AddDays(30));
}
yield return request;

@ -83,7 +83,7 @@ public class PirateTheNet : TorrentIndexerBase<UserPassTorrentBaseSettings>
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}
@ -275,7 +275,7 @@ public class PirateTheNetParser : IParseIndexerResponse
}
else if (added.StartsWith("Yesterday "))
{
release.PublishDate = DateTime.Now.Date + DateTime.ParseExact(added.Split(" ", 2).Last(), "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay - TimeSpan.FromDays(1);
release.PublishDate = DateTime.Now.AddDays(-1).Date + DateTime.ParseExact(added.Split(" ", 2).Last(), "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
}
else
{

@ -74,7 +74,7 @@ namespace NzbDrone.Core.Indexers.Definitions
throw new IndexerAuthException(errorMessage ?? "Unknown error message, please report");
}
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded");
}

@ -92,7 +92,7 @@ public class PreToMe : TorrentIndexerBase<PreToMeSettings>
throw new IndexerAuthException(errorMessage ?? "Unknown error message, please report.");
}
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded");
}

@ -69,7 +69,7 @@ namespace NzbDrone.Core.Indexers.Definitions
if (response.Content != null && response.Content.Contains("/logout.php"))
{
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
_logger.Debug("RevolutionTT authentication succeeded");
}

@ -76,7 +76,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded");
}

@ -86,7 +86,7 @@ public class Shazbat : TorrentIndexerBase<ShazbatSettings>
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -108,7 +108,7 @@ public class SpeedCD : TorrentIndexerBase<SpeedCDSettings>
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -83,7 +83,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("TVVault authentication succeeded.");
}

@ -86,7 +86,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Toloka.to authentication succeeded.");
}

@ -79,7 +79,7 @@ namespace NzbDrone.Core.Indexers.Definitions
}
cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("TorrentBytes authentication succeeded.");
}

@ -84,7 +84,7 @@ public class XSpeeds : TorrentIndexerBase<UserPassTorrentBaseSettings>
}
var cookies = response.GetCookies();
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(cookies, DateTime.Now.AddDays(30));
_logger.Debug("Authentication succeeded.");
}

@ -130,7 +130,7 @@ namespace NzbDrone.Core.Indexers.Definitions
response = await ExecuteAuth(authLoginRequest3);
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30));
}
private static string Sha1Hash(string input)

@ -406,7 +406,7 @@ namespace NzbDrone.Core.Indexers
throw new CloudFlareProtectionException(response);
}
UpdateCookies(request.HttpRequest.Cookies, DateTime.Now + TimeSpan.FromDays(30));
UpdateCookies(request.HttpRequest.Cookies, DateTime.Now.AddDays(30));
return new IndexerResponse(request, response);
}

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Indexers
public DateTime GetIndexerCookiesExpirationDate(int indexerId)
{
return GetProviderStatus(indexerId)?.CookiesExpirationDate ?? DateTime.Now + TimeSpan.FromDays(12);
return GetProviderStatus(indexerId)?.CookiesExpirationDate ?? DateTime.Now.AddDays(12);
}
public void UpdateRssSyncStatus(int indexerId, ReleaseInfo releaseInfo)

@ -116,7 +116,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
if (inStartupGracePeriod && minimumBackOff == TimeSpan.Zero && status.DisabledTill.HasValue)
{
var maximumDisabledTill = now + TimeSpan.FromSeconds(EscalationBackOff.Periods[1]);
var maximumDisabledTill = now.AddSeconds(EscalationBackOff.Periods[1]);
if (maximumDisabledTill < status.DisabledTill)
{
status.DisabledTill = maximumDisabledTill;

Loading…
Cancel
Save