From 49644cb18782e3c85f676b9af1843402aa602e82 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:20:24 +0300 Subject: [PATCH] Fix FileSaver Progress (#2277) --- .../Essentials/FileSaver/FileSaverImplementation.android.cs | 2 +- .../Essentials/FileSaver/FileSaverImplementation.shared.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.android.cs b/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.android.cs index 20dbbec78d..4fa686e5d7 100644 --- a/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.android.cs +++ b/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.android.cs @@ -102,7 +102,7 @@ static async Task SaveDocument(AndroidUri uri, Stream stream, IProgress< { await fileOutputStream.WriteAsync(buffer, 0, bytesRead).WaitAsync(cancellationToken).ConfigureAwait(false); totalRead += bytesRead; - progress?.Report(totalRead / stream.Length); + progress?.Report((double)totalRead / stream.Length); } if (fileOutputStream.Channel is not null) diff --git a/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.shared.cs b/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.shared.cs index cd9ffedd89..d222fb4a2a 100644 --- a/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.shared.cs +++ b/src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.shared.cs @@ -78,7 +78,7 @@ static async Task WriteStream(Stream stream, string filePath, IProgress? try { int bytesRead; - long totalRead = 0; + double totalRead = 0; while ((bytesRead = await stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)) > 0) { await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);