mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Added new helper to find the best file size format given a long with file size in bytes.
Added view under system to see which folders have not been processed in dropDir.
This commit is contained in:
parent
cea511a460
commit
54e7092e2d
7 changed files with 214 additions and 2 deletions
49
NzbDrone.Core/Helpers/FileSizeFormatHelpercs.cs
Normal file
49
NzbDrone.Core/Helpers/FileSizeFormatHelpercs.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
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