mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 11:48:26 -07:00
Fix: Size will be displayed in best format when rejected (instead of bytes). It will also be displayed as info so it shows in the normal log.
This commit is contained in:
parent
207ea607a7
commit
2bf97fd76f
3 changed files with 5 additions and 4 deletions
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Helpers
|
||||
{
|
||||
public 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)
|
||||
{
|
||||
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