Skip to content

Commit 3c5e3aa

Browse files
Fix: Fixed an issue where drive capacity was reported incorrectly (#16960)
1 parent e32d518 commit 3c5e3aa

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/Files.App/Data/Models/ByteSize.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ public struct ByteSize : IEquatable<ByteSize>, IComparable<ByteSize>
99
{
1010
private static readonly FrozenDictionary<string, string> units = new Dictionary<string, string>
1111
{
12-
[ByteSizeLib.ByteSize.BitSymbol] = "ByteSymbol".ToLocalized(),
13-
[ByteSizeLib.ByteSize.ByteSymbol] = "ByteSymbol".ToLocalized(),
14-
[ByteSizeLib.ByteSize.KibiByteSymbol] = "KiloByteSymbol".ToLocalized(),
15-
[ByteSizeLib.ByteSize.MebiByteSymbol] = "MegaByteSymbol".ToLocalized(),
16-
[ByteSizeLib.ByteSize.GibiByteSymbol] = "GigaByteSymbol".ToLocalized(),
17-
[ByteSizeLib.ByteSize.TebiByteSymbol] = "TeraByteSymbol".ToLocalized(),
18-
[ByteSizeLib.ByteSize.PebiByteSymbol] = "PetaByteSymbol".ToLocalized(),
12+
[ByteSizeLib.ByteSize.BitSymbol] = Strings.ByteSymbol.ToLocalized(),
13+
[ByteSizeLib.ByteSize.ByteSymbol] = Strings.ByteSymbol.ToLocalized(),
14+
[ByteSizeLib.ByteSize.KiloByteSymbol] = Strings.KiloByteSymbol.ToLocalized(),
15+
[ByteSizeLib.ByteSize.MegaByteSymbol] = Strings.MegaByteSymbol.ToLocalized(),
16+
[ByteSizeLib.ByteSize.GigaByteSymbol] = Strings.GigaByteSymbol.ToLocalized(),
17+
[ByteSizeLib.ByteSize.TeraByteSymbol] = Strings.TeraByteSymbol.ToLocalized(),
18+
[ByteSizeLib.ByteSize.PetaByteSymbol] = Strings.PetaByteSymbol.ToLocalized(),
1919
}.ToFrozenDictionary();
2020

2121
private readonly ByteSizeLib.ByteSize size;
@@ -28,7 +28,7 @@ public ulong Bytes
2828
=> (ulong)size.Bytes;
2929

3030
public string ShortString
31-
=> $"{size.LargestWholeNumberBinaryValue:0.##} {units[size.LargestWholeNumberBinarySymbol]}";
31+
=> $"{size.LargestWholeNumberDecimalValue:0.##} {units[size.LargestWholeNumberDecimalSymbol]}";
3232

3333
public string LongString
3434
=> $"{ShortString} ({size.Bytes:#,##0} {units[ByteSizeLib.ByteSize.ByteSymbol]})";

src/Files.App/Extensions/StringExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public static string WithEnding(this string str, string ending)
6060

6161
private static readonly Dictionary<string, string> abbreviations = new()
6262
{
63-
{ "KiB", "KiloByteSymbol".GetLocalizedResource() },
64-
{ "MiB", "MegaByteSymbol".GetLocalizedResource() },
65-
{ "GiB", "GigaByteSymbol".GetLocalizedResource() },
66-
{ "TiB", "TeraByteSymbol".GetLocalizedResource() },
67-
{ "PiB", "PetaByteSymbol".GetLocalizedResource() },
68-
{ "B", "ByteSymbol".GetLocalizedResource() },
69-
{ "b", "ByteSymbol".GetLocalizedResource() }
63+
{ ByteSize.KiloByteSymbol, Strings.KiloByteSymbol.GetLocalizedResource() },
64+
{ ByteSize.MegaByteSymbol, Strings.MegaByteSymbol.GetLocalizedResource() },
65+
{ ByteSize.GigaByteSymbol, Strings.GigaByteSymbol.GetLocalizedResource() },
66+
{ ByteSize.TeraByteSymbol, Strings.TeraByteSymbol.GetLocalizedResource() },
67+
{ ByteSize.PetaByteSymbol, Strings.PetaByteSymbol.GetLocalizedResource() },
68+
{ ByteSize.BitSymbol, Strings.ByteSymbol.GetLocalizedResource() },
69+
{ ByteSize.ByteSymbol, Strings.ByteSymbol.GetLocalizedResource() }
7070
};
7171

7272
public static string ConvertSizeAbbreviation(this string value)
@@ -83,7 +83,7 @@ public static string ConvertSizeAbbreviation(this string value)
8383
public static string ToSizeString(this long size) => ByteSize.FromBytes(size).ToSizeString();
8484
public static string ToSizeString(this ulong size) => ByteSize.FromBytes(size).ToSizeString();
8585
public static string ToSizeString(this decimal size) => ByteSize.FromBytes((double)size).ToSizeString();
86-
public static string ToSizeString(this ByteSize size) => size.ToBinaryString().ConvertSizeAbbreviation();
86+
public static string ToSizeString(this ByteSize size) => size.ToString().ConvertSizeAbbreviation();
8787

8888
public static string ToLongSizeString(this long size) => ByteSize.FromBytes(size).ToLongSizeString();
8989
public static string ToLongSizeString(this ulong size) => ByteSize.FromBytes(size).ToLongSizeString();

0 commit comments

Comments
 (0)