1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ui] fix WIM image application progress

* Use UpdateProgressWithInfo() always
* Remove cubic progress and use an estimated overhead instead
This commit is contained in:
Pete Batard 2019-08-25 14:09:28 +01:00
parent 0f6794a72b
commit 398baf23d8
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
3 changed files with 31 additions and 31 deletions

View file

@ -63,6 +63,7 @@ static float format_percent = 0.0f;
static int task_number = 0;
extern const int nb_steps[FS_MAX];
extern uint32_t dur_mins, dur_secs;
extern uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
static int actual_fs_type, wintogo_index = -1, wininst_index = 0;
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, fast_zeroing, enable_file_indexing, write_as_image;
extern BOOL use_vds;
@ -1310,8 +1311,7 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
PrintInfo(0, MSG_218, (ulPercentCompleted < 100) ? 1 : 2, 2);
UpdateProgress(OP_CREATE_FS, (float)ulPercentCompleted);
} else {
PrintInfo(0, MSG_217, (float)ulPercentCompleted);
UpdateProgress(OP_FORMAT, (float)ulPercentCompleted);
UpdateProgressWithInfo(OP_FORMAT, MSG_217, ulPercentCompleted, 100);
}
hr = hr2;
if (hr == S_OK)
@ -2196,8 +2196,7 @@ static BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
Sleep(200);
AltUnmountVolume(ms_efi, FALSE);
}
PrintInfo(0, MSG_267, 99.9f);
UpdateProgress(OP_FILE_COPY, 99.9f);
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_proc_files + 2 * wim_extra_files, wim_nb_files);
// The following are non fatal if they fail
@ -2232,8 +2231,7 @@ static BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
uprintf("Could not write '%s'", unattend_path);
if (fd != NULL)
fclose(fd);
PrintInfo(0, MSG_267, 100.0f);
UpdateProgress(OP_FILE_COPY, 100.0f);
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_nb_files, wim_nb_files);
return TRUE;
}

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.7.1568"
CAPTION "Rufus 3.7.1569"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -394,8 +394,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,1568,0
PRODUCTVERSION 3,7,1568,0
FILEVERSION 3,7,1569,0
PRODUCTVERSION 3,7,1569,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -413,13 +413,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.7.1568"
VALUE "FileVersion", "3.7.1569"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.7.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.7.1568"
VALUE "ProductVersion", "3.7.1569"
END
END
BLOCK "VarFileInfo"

View file

@ -100,12 +100,12 @@ PF_TYPE_DECL(WINAPI, DWORD, WIMRegisterMessageCallback, (HANDLE, FARPROC, PVOID)
PF_TYPE_DECL(WINAPI, DWORD, WIMUnregisterMessageCallback, (HANDLE, FARPROC));
PF_TYPE_DECL(RPC_ENTRY, RPC_STATUS, UuidCreate, (UUID __RPC_FAR*));
uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
static uint8_t wim_flags = 0;
static char sevenzip_path[MAX_PATH];
static const char conectix_str[] = VHD_FOOTER_COOKIE;
static uint32_t wim_nb_files, wim_proc_files;
static BOOL count_files;
static uint64_t LastRefresh;
static BOOL Get7ZipPath(void)
{
@ -572,7 +572,6 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
PWIN32_FIND_DATA pFileData;
const char* level = NULL;
uint64_t size;
float apply_percent;
switch (dwMsgId) {
case WIM_MSG_PROGRESS:
@ -593,20 +592,13 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
if (count_files) {
wim_nb_files++;
} else {
wim_proc_files++;
if (GetTickCount64() > LastRefresh + 100) {
// At the end of an actual apply, the WIM API re-lists a bunch of directories it
// already processed, so we end up with more entries than counted - ignore those.
if (wim_proc_files > wim_nb_files)
wim_proc_files = wim_nb_files;
LastRefresh = GetTickCount64();
// x^3 progress, so as to give a better idea right from the onset of the dismal
// speed with which the WIM API actually applies files...
apply_percent = 4.636942595f * ((float)wim_proc_files) / ((float)wim_nb_files);
apply_percent = apply_percent * apply_percent * apply_percent;
PrintInfo(0, MSG_267, apply_percent);
UpdateProgress(OP_FILE_COPY, apply_percent);
}
// At the end of an actual apply, the WIM API re-lists a bunch of directories it already processed,
// so, even as we try to compensate, we might end up with more entries than counted - ignore those.
if (wim_proc_files < wim_nb_files)
wim_proc_files++;
else
wim_extra_files++;
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_proc_files, wim_nb_files);
}
// Halt on error
if (IS_ERROR(FormatStatus)) {
@ -697,20 +689,30 @@ static DWORD WINAPI WimApplyImageThread(LPVOID param)
// Run a first pass using WIM_FLAG_NO_APPLY to count the files
wim_nb_files = 0;
wim_proc_files = 0;
LastRefresh = 0;
wim_extra_files = 0;
count_files = TRUE;
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) {
uprintf(" Could not count the files to apply: %s", WindowsErrorString());
goto out;
}
// The latest Windows 10 ISOs have a ~17.5% discrepancy between the number of
// files and directories actually applied vs. the ones counted when not applying.
// Therefore, we add a 'safe' 20% to our counted files to compensate for yet
// another dismal Microsoft progress reporting API...
wim_nb_files += wim_nb_files / 5;
count_files = FALSE;
// Actual apply
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_FILEINFO)) {
uprintf(" Could not apply image: %s", WindowsErrorString());
goto out;
}
PrintInfo(0, MSG_267, 99.8f);
UpdateProgress(OP_FILE_COPY, 99.8f);
// Ensure that we'll pick if need to readjust our 20% above from user reports
if (wim_extra_files > 0)
uprintf("Notice: An extra %d files and directories were applied, from the %d expected",
wim_extra_files, wim_nb_files);
// Re-use extra files as the final progress step
wim_extra_files = (wim_nb_files - wim_proc_files) / 3;
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_proc_files + wim_extra_files, wim_nb_files);
r = TRUE;
out: