Skip to content

Commit 9c82623

Browse files
authored
Fix: Fixed OverflowException in UpdateSelectionSize (#16165)
1 parent 6270935 commit 9c82623

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ public bool IsUncompressedItemSizeVisibile
183183
set => SetProperty(ref isUncompressedItemSizeVisibile, value);
184184
}
185185

186-
private long itemSizeBytes;
187-
public long ItemSizeBytes
186+
private decimal itemSizeBytes;
187+
public decimal ItemSizeBytes
188188
{
189189
get => itemSizeBytes;
190190
set => SetProperty(ref itemSizeBytes, value);

src/Files.App/Extensions/StringExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static string ConvertSizeAbbreviation(this string value)
8282
public static string ToSizeString(this double size) => ByteSize.FromBytes(size).ToSizeString();
8383
public static string ToSizeString(this long size) => ByteSize.FromBytes(size).ToSizeString();
8484
public static string ToSizeString(this ulong size) => ByteSize.FromBytes(size).ToSizeString();
85+
public static string ToSizeString(this decimal size) => ByteSize.FromBytes((double)size).ToSizeString();
8586
public static string ToSizeString(this ByteSize size) => size.ToBinaryString().ConvertSizeAbbreviation();
8687

8788
public static string ToLongSizeString(this long size) => ByteSize.FromBytes(size).ToLongSizeString();

src/Files.App/Views/Layouts/BaseLayoutPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ public void UpdateSelectionSize()
702702
var isSizeKnown = !items.Any(item => string.IsNullOrEmpty(item.FileSize));
703703
if (isSizeKnown)
704704
{
705-
long size = items.Sum(item => item.FileSizeBytes);
705+
decimal size = items.Sum(item => item.FileSizeBytes);
706706
SelectedItemsPropertiesViewModel.ItemSizeBytes = size;
707707
SelectedItemsPropertiesViewModel.ItemSize = size.ToSizeString();
708708
}

0 commit comments

Comments
 (0)