|
|
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
|
|
|
@ -284,90 +284,89 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|
|
|
|
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);
|
|
|
|
|
var parsed = VersionRegex.Match(version);
|
|
|
|
|
|
|
|
|
|
int actualMajor;
|
|
|
|
|
int actualMinor;
|
|
|
|
|
int actualPatch;
|
|
|
|
|
string actualCandidate;
|
|
|
|
|
|
|
|
|
|
if (!parsed.Success)
|
|
|
|
|
{
|
|
|
|
|
if (!version.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
if (version == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
actualMajor = 1;
|
|
|
|
|
actualMinor = 1;
|
|
|
|
|
actualPatch = 0;
|
|
|
|
|
actualCandidate = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
if (version.Major > major)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (actualMajor < major)
|
|
|
|
|
else if (version.Major < major)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (actualMinor > minor)
|
|
|
|
|
if (version.Minor > minor)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (actualMinor < minor)
|
|
|
|
|
else if (version.Minor < minor)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (actualPatch > patch)
|
|
|
|
|
if (version.Build > patch)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (actualPatch < patch)
|
|
|
|
|
else if (version.Build < patch)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (actualCandidate.IsNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (candidate.IsNullOrWhiteSpace())
|
|
|
|
|
|
|
|
|
|
private Version ParseVersion(string version)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
var parsed = VersionRegex.Match(version);
|
|
|
|
|
|
|
|
|
|
int major;
|
|
|
|
|
int minor;
|
|
|
|
|
int patch;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
return actualCandidate.CompareTo(candidate) > 0;
|
|
|
|
|
if (!version.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
major = 1;
|
|
|
|
|
minor = 1;
|
|
|
|
|
patch = 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 ValidationFailure("Version", "Unknown Version: " + version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rawVersion.Equals("develop", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return new NzbDroneValidationFailure("Version", "Sabnzbd develop version, assuming version 1.1.0 or higher.")
|
|
|
|
|
{
|
|
|
|
@ -376,18 +375,12 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ValidationFailure("Version", "Unknown Version: " + version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var major = Convert.ToInt32(parsed.Groups["major"].Value);
|
|
|
|
|
var minor = Convert.ToInt32(parsed.Groups["minor"].Value);
|
|
|
|
|
|
|
|
|
|
if (major >= 1)
|
|
|
|
|
if (version.Major >= 1)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (minor >= 7)
|
|
|
|
|
if (version.Minor >= 7)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|