1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

New: automatically switch back to master if current branch is invalid

This commit is contained in:
Keivan Beigi 2014-10-28 16:48:37 -07:00
parent 95d67ef9f4
commit aa68faaf88
4 changed files with 27 additions and 2 deletions

View File

@ -23,6 +23,13 @@ public void finds_update_when_version_lower()
Subject.GetLatestUpdate("master", new Version(2, 0)).Should().NotBeNull();
}
[Test]
public void should_get_master_if_branch_doesnt_exit()
{
UseRealHttp();
Subject.GetLatestUpdate("master2", new Version(2, 0)).Should().NotBeNull();
}
[Test]
public void should_get_recent_updates()
@ -37,6 +44,7 @@ public void should_get_recent_updates()
recent.Should().OnlyContain(c => c.ReleaseDate.Year == 2014);
recent.Should().OnlyContain(c => c.Changes.New != null);
recent.Should().OnlyContain(c => c.Changes.Fixed != null);
recent.Should().OnlyContain(c => c.Branch == branch);
}
}
}

View File

@ -57,7 +57,7 @@ public void Handle(ApplicationStartedEvent message)
{
new ScheduledTask{ Interval = 1, TypeName = typeof(TrackedCommandCleanupCommand).FullName},
new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName},
new ScheduledTask{ Interval = 1*60, TypeName = typeof(ApplicationUpdateCommand).FullName},
new ScheduledTask{ Interval = 6*60, TypeName = typeof(ApplicationUpdateCommand).FullName},
new ScheduledTask{ Interval = 1*60, TypeName = typeof(TrimLogCommand).FullName},
new ScheduledTask{ Interval = 3*60, TypeName = typeof(UpdateSceneMappingCommand).FullName},
new ScheduledTask{ Interval = 6*60, TypeName = typeof(CheckHealthCommand).FullName},

View File

@ -1,4 +1,5 @@
using NLog;
using System;
using NLog;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Configuration;
@ -40,6 +41,21 @@ public UpdatePackage AvailableUpdate()
{
_logger.ProgressDebug("No update available.");
}
else if (latestAvailable.Branch != _configFileProvider.Branch)
{
try
{
_logger.Warn("[{0}] isn't a valid branch. Switching back to [master]", _configFileProvider.Branch);
var config = _configFileProvider.GetConfigDictionary();
config["Branch"] = _configFileProvider.Branch;
_configFileProvider.SaveConfigDictionary(config);
}
catch (Exception e)
{
_logger.ErrorException("couldn't revert back to master.", e);
}
}
return latestAvailable;
}

View File

@ -11,5 +11,6 @@ public class UpdatePackage
public String Url { get; set; }
public UpdateChanges Changes { get; set; }
public String Hash { get; set; }
public String Branch { get; set; }
}
}