Skip to content

Commit

Permalink
- Fix ToHumanReadable
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed Aug 24, 2021
1 parent 1c268bb commit 4846502
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/OpenDirectoryDownloader/Helpers/FileSizeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ public static long ParseFileSize(string value, int kbValue = 1024, bool throwExc
private static readonly string[] sizeSuffixes = { "B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" };
private static readonly string[] sizeSuffixesBit = { "b", "kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib" };

public static string ToHumanReadable(long size, bool useBits = false)
public static string ToHumanReadable(long? size, bool useBits = false)
{
Debug.Assert(sizeSuffixes.Length > 0);

const string formatTemplate = "{0}{1:#.##} {2}";

if (size == null)
{
return "-";
}

if (size == 0)
{
return string.Format(formatTemplate, null, 0, sizeSuffixes[0]);
Expand Down

0 comments on commit 4846502

Please sign in to comment.