mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 09:21:57 +00:00
Fixed: Parsing of SABnzbd develop version
This commit is contained in:
parent
d33de0d158
commit
4447b7cd62
1 changed files with 71 additions and 78 deletions
|
@ -30,13 +30,13 @@ public Sabnzbd(ISabnzbdProxy proxy,
|
|||
}
|
||||
|
||||
// patch can be a number (releases) or 'x' (git)
|
||||
private static readonly Regex VersionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+|x)(?<candidate>.*)", RegexOptions.Compiled);
|
||||
private static readonly Regex VersionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+|x)", RegexOptions.Compiled);
|
||||
|
||||
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContents)
|
||||
{
|
||||
var category = Settings.TvCategory;
|
||||
var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
|
||||
|
||||
var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings);
|
||||
|
||||
if (response != null && response.Ids.Any())
|
||||
|
@ -284,110 +284,103 @@ protected override void Test(List<ValidationFailure> failures)
|
|||
failures.AddIfNotNull(TestCategory());
|
||||
}
|
||||
|
||||
private bool HasVersion(int major, int minor, int patch = 0, string candidate = null)
|
||||
private bool HasVersion(int major, int minor, int patch = 0)
|
||||
{
|
||||
candidate = candidate ?? string.Empty;
|
||||
var rawVersion = _proxy.GetVersion(Settings);
|
||||
var version = ParseVersion(rawVersion);
|
||||
|
||||
var version = _proxy.GetVersion(Settings);
|
||||
if (version == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version.Major > major)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (version.Major < major)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version.Minor > minor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (version.Minor < minor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (version.Build > patch)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (version.Build < patch)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Version ParseVersion(string version)
|
||||
{
|
||||
var parsed = VersionRegex.Match(version);
|
||||
|
||||
int actualMajor;
|
||||
int actualMinor;
|
||||
int actualPatch;
|
||||
string actualCandidate;
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
|
||||
if (!parsed.Success)
|
||||
if (parsed.Success)
|
||||
{
|
||||
major = Convert.ToInt32(parsed.Groups["major"].Value);
|
||||
minor = Convert.ToInt32(parsed.Groups["minor"].Value);
|
||||
patch = Convert.ToInt32(parsed.Groups["patch"].Value.Replace("x", "0"));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!version.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
actualMajor = 1;
|
||||
actualMinor = 1;
|
||||
actualPatch = 0;
|
||||
actualCandidate = null;
|
||||
major = 1;
|
||||
minor = 1;
|
||||
patch = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
actualMajor = Convert.ToInt32(parsed.Groups["major"].Value);
|
||||
actualMinor = Convert.ToInt32(parsed.Groups["minor"].Value);
|
||||
actualPatch = Convert.ToInt32(parsed.Groups["patch"].Value.Replace("x", ""));
|
||||
actualCandidate = parsed.Groups["candidate"].Value.ToUpper();
|
||||
}
|
||||
|
||||
if (actualMajor > major)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (actualMajor < major)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (actualMinor > minor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (actualMinor < minor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (actualPatch > patch)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (actualPatch < patch)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (actualCandidate.IsNullOrWhiteSpace())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (candidate.IsNullOrWhiteSpace())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return actualCandidate.CompareTo(candidate) > 0;
|
||||
}
|
||||
return new Version(major, minor, patch);
|
||||
}
|
||||
|
||||
private ValidationFailure TestConnectionAndVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
var version = _proxy.GetVersion(Settings);
|
||||
var parsed = VersionRegex.Match(version);
|
||||
var rawVersion = _proxy.GetVersion(Settings);
|
||||
var version = ParseVersion(rawVersion);
|
||||
|
||||
if (!parsed.Success)
|
||||
if (version == null)
|
||||
{
|
||||
if (version.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return new NzbDroneValidationFailure("Version", "Sabnzbd develop version, assuming version 1.1.0 or higher.")
|
||||
{
|
||||
IsWarning = true,
|
||||
DetailedDescription = "Radarr may not be able to support new features added to SABnzbd when running develop versions."
|
||||
};
|
||||
}
|
||||
|
||||
return new ValidationFailure("Version", "Unknown Version: " + version);
|
||||
}
|
||||
|
||||
var major = Convert.ToInt32(parsed.Groups["major"].Value);
|
||||
var minor = Convert.ToInt32(parsed.Groups["minor"].Value);
|
||||
if (rawVersion.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return new NzbDroneValidationFailure("Version", "Sabnzbd develop version, assuming version 1.1.0 or higher.")
|
||||
{
|
||||
IsWarning = true,
|
||||
DetailedDescription = "Radarr may not be able to support new features added to SABnzbd when running develop versions."
|
||||
};
|
||||
}
|
||||
|
||||
if (major >= 1)
|
||||
if (version.Major >= 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (minor >= 7)
|
||||
if (version.Minor >= 7)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue