[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.
This commit is contained in:
Tim Abdiukov 2025-05-03 23:42:36 +02:00 committed by GitHub
parent e6f5065f32
commit a9ba54f678
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;