1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Fixed parsing of NzbClub releases below 1GB

This commit is contained in:
Mark McDowall 2013-07-16 23:58:50 -07:00
parent 0c12183b93
commit 6a9ca9295f

View File

@ -133,7 +133,7 @@ public static string ParseHeader(string header)
return header;
}
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)",
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+)\W?(?<unit>GB|MB|GiB|MiB)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -148,11 +148,17 @@ public static long GetReportSize(string sizeString)
var unit = match[0].Groups["unit"].Value;
if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1048576L);
if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) ||
unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase))
{
return Convert.ToInt32(value).Megabytes();
}
if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase))
return Convert.ToInt64(value * 1073741824L);
if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) ||
unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase))
{
return Convert.ToInt32(value).Gigabytes();
}
}
return 0;
}