mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
SearchResult Controller added.
Force Download added.
This commit is contained in:
parent
aa24e4cac7
commit
cef7b6a8dc
25 changed files with 358 additions and 128 deletions
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Helpers
|
||||
{
|
||||
public static class FileSizeFormatHelper
|
||||
{
|
||||
private const Decimal OneKiloByte = 1024M;
|
||||
private const Decimal OneMegaByte = OneKiloByte * 1024M;
|
||||
private const Decimal OneGigaByte = OneMegaByte * 1024M;
|
||||
|
||||
public static string Format(long bytes, int precision = 0)
|
||||
{
|
||||
if (bytes == 0)
|
||||
return "0B";
|
||||
|
||||
decimal size = Convert.ToDecimal(bytes);
|
||||
|
||||
string suffix;
|
||||
|
||||
if (size > OneGigaByte)
|
||||
{
|
||||
size /= OneGigaByte;
|
||||
suffix = "GB";
|
||||
}
|
||||
|
||||
else if (size > OneMegaByte)
|
||||
{
|
||||
size /= OneMegaByte;
|
||||
suffix = "MB";
|
||||
}
|
||||
|
||||
else if (size > OneKiloByte)
|
||||
{
|
||||
size /= OneKiloByte;
|
||||
suffix = "KB";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
suffix = " B";
|
||||
}
|
||||
|
||||
return String.Format("{0:N" + precision + "}{1}", size, suffix);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue