mirror of
https://github.com/fergalmoran/Readarr.git
synced 2025-12-26 19:38:42 +00:00
Add one minute back-off level for all providers
(cherry picked from commit d8f314ff0ef64e8d90b21b7865e46be74db5e570) Closes #2792
This commit is contained in:
@@ -34,6 +34,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
|
|||||||
|
|
||||||
public class ProviderStatusServiceFixture : CoreTest<MockProviderStatusService>
|
public class ProviderStatusServiceFixture : CoreTest<MockProviderStatusService>
|
||||||
{
|
{
|
||||||
|
private readonly TimeSpan _disabledTillPrecision = TimeSpan.FromMilliseconds(500);
|
||||||
private DateTime _epoch;
|
private DateTime _epoch;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
@@ -90,7 +91,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
|
|||||||
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
||||||
status.Should().NotBeNull();
|
status.Should().NotBeNull();
|
||||||
status.DisabledTill.Should().HaveValue();
|
status.DisabledTill.Should().HaveValue();
|
||||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
|
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(1), _disabledTillPrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -133,7 +134,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
|
|||||||
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
||||||
status.Should().NotBeNull();
|
status.Should().NotBeNull();
|
||||||
status.DisabledTill.Should().HaveValue();
|
status.DisabledTill.Should().HaveValue();
|
||||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(15), 500);
|
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -160,7 +161,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
|
|||||||
status.Should().NotBeNull();
|
status.Should().NotBeNull();
|
||||||
|
|
||||||
origStatus.EscalationLevel.Should().Be(3);
|
origStatus.EscalationLevel.Should().Be(3);
|
||||||
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
|
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
namespace NzbDrone.Core.ThingiProvider.Status
|
namespace NzbDrone.Core.ThingiProvider.Status
|
||||||
{
|
{
|
||||||
public static class EscalationBackOff
|
public static class EscalationBackOff
|
||||||
{
|
{
|
||||||
public static readonly int[] Periods =
|
public static readonly int[] Periods =
|
||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
|
60,
|
||||||
5 * 60,
|
5 * 60,
|
||||||
15 * 60,
|
15 * 60,
|
||||||
30 * 60,
|
30 * 60,
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
|
|||||||
|
|
||||||
if (inStartupGracePeriod && minimumBackOff == TimeSpan.Zero && status.DisabledTill.HasValue)
|
if (inStartupGracePeriod && minimumBackOff == TimeSpan.Zero && status.DisabledTill.HasValue)
|
||||||
{
|
{
|
||||||
var maximumDisabledTill = now + TimeSpan.FromSeconds(EscalationBackOff.Periods[1]);
|
var maximumDisabledTill = now + TimeSpan.FromSeconds(EscalationBackOff.Periods[2]);
|
||||||
if (maximumDisabledTill < status.DisabledTill)
|
if (maximumDisabledTill < status.DisabledTill)
|
||||||
{
|
{
|
||||||
status.DisabledTill = maximumDisabledTill;
|
status.DisabledTill = maximumDisabledTill;
|
||||||
|
|||||||
Reference in New Issue
Block a user