From a9ba54f67888047553e972f81add080395ad4bbf Mon Sep 17 00:00:00 2001 From: Tim Abdiukov Date: Sat, 3 May 2025 23:42:36 +0200 Subject: [PATCH] [DWNL] Improve user experience and fix progress output (#7903) - `CBindStatusCallback_UpdateProgress`: * Rework the failsafe check to enable percentage to be at 100%. * More thorough failsafe check, to avoid displaying 100% (or even 101%) where the actual and expected file sizes don't match. - `case BINDSTATUS_ENDDOWNLOADDATA`: Do update the progress one last time to be at 100%, on download success. --- base/applications/network/dwnl/dwnl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/base/applications/network/dwnl/dwnl.c b/base/applications/network/dwnl/dwnl.c index 74826ef8052..3eb3806ce22 100644 --- a/base/applications/network/dwnl/dwnl.c +++ b/base/applications/network/dwnl/dwnl.c @@ -73,7 +73,8 @@ CBindStatusCallback_UpdateProgress(CBindStatusCallback *This) UINT Percentage; Percentage = (UINT)((This->Progress * 100) / This->Size); - if (Percentage > 99) + // If percentage is greater than 99% but sizes don't match, do a failsafe. + if ((Percentage > 99) && (This->Progress != This->Size)) Percentage = 99; LoadStringW(NULL, IDS_BYTES_DOWNLOADED_FULL, szMessage, ARRAYSIZE(szMessage)); @@ -246,6 +247,10 @@ CBindStatusCallback_OnProgress(IBindStatusCallback *iface, break; case BINDSTATUS_ENDDOWNLOADDATA: + /* Since download is completed, update progress one last time to be at 100% */ + This->Progress = This->Size; // Ensure progress == total size + CBindStatusCallback_UpdateProgress(This); // Show 100% progress now + ConResPrintf(StdOut, IDS_FILE_SAVED); break;