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:
parent
0f6794a72b
commit
398baf23d8
3 changed files with 31 additions and 31 deletions
10
src/format.c
10
src/format.c
|
@ -63,6 +63,7 @@ static float format_percent = 0.0f;
|
||||||
static int task_number = 0;
|
static int task_number = 0;
|
||||||
extern const int nb_steps[FS_MAX];
|
extern const int nb_steps[FS_MAX];
|
||||||
extern uint32_t dur_mins, dur_secs;
|
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;
|
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 force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, fast_zeroing, enable_file_indexing, write_as_image;
|
||||||
extern BOOL use_vds;
|
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);
|
PrintInfo(0, MSG_218, (ulPercentCompleted < 100) ? 1 : 2, 2);
|
||||||
UpdateProgress(OP_CREATE_FS, (float)ulPercentCompleted);
|
UpdateProgress(OP_CREATE_FS, (float)ulPercentCompleted);
|
||||||
} else {
|
} else {
|
||||||
PrintInfo(0, MSG_217, (float)ulPercentCompleted);
|
UpdateProgressWithInfo(OP_FORMAT, MSG_217, ulPercentCompleted, 100);
|
||||||
UpdateProgress(OP_FORMAT, (float)ulPercentCompleted);
|
|
||||||
}
|
}
|
||||||
hr = hr2;
|
hr = hr2;
|
||||||
if (hr == S_OK)
|
if (hr == S_OK)
|
||||||
|
@ -2196,8 +2196,7 @@ static BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
AltUnmountVolume(ms_efi, FALSE);
|
AltUnmountVolume(ms_efi, FALSE);
|
||||||
}
|
}
|
||||||
PrintInfo(0, MSG_267, 99.9f);
|
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_proc_files + 2 * wim_extra_files, wim_nb_files);
|
||||||
UpdateProgress(OP_FILE_COPY, 99.9f);
|
|
||||||
|
|
||||||
// The following are non fatal if they fail
|
// 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);
|
uprintf("Could not write '%s'", unattend_path);
|
||||||
if (fd != NULL)
|
if (fd != NULL)
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
PrintInfo(0, MSG_267, 100.0f);
|
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_nb_files, wim_nb_files);
|
||||||
UpdateProgress(OP_FILE_COPY, 100.0f);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.7.1568"
|
CAPTION "Rufus 3.7.1569"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -394,8 +394,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,7,1568,0
|
FILEVERSION 3,7,1569,0
|
||||||
PRODUCTVERSION 3,7,1568,0
|
PRODUCTVERSION 3,7,1569,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -413,13 +413,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://akeo.ie"
|
VALUE "Comments", "https://akeo.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.7.1568"
|
VALUE "FileVersion", "3.7.1569"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.7.exe"
|
VALUE "OriginalFilename", "rufus-3.7.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.7.1568"
|
VALUE "ProductVersion", "3.7.1569"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
40
src/vhd.c
40
src/vhd.c
|
@ -100,12 +100,12 @@ PF_TYPE_DECL(WINAPI, DWORD, WIMRegisterMessageCallback, (HANDLE, FARPROC, PVOID)
|
||||||
PF_TYPE_DECL(WINAPI, DWORD, WIMUnregisterMessageCallback, (HANDLE, FARPROC));
|
PF_TYPE_DECL(WINAPI, DWORD, WIMUnregisterMessageCallback, (HANDLE, FARPROC));
|
||||||
PF_TYPE_DECL(RPC_ENTRY, RPC_STATUS, UuidCreate, (UUID __RPC_FAR*));
|
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 uint8_t wim_flags = 0;
|
||||||
static char sevenzip_path[MAX_PATH];
|
static char sevenzip_path[MAX_PATH];
|
||||||
static const char conectix_str[] = VHD_FOOTER_COOKIE;
|
static const char conectix_str[] = VHD_FOOTER_COOKIE;
|
||||||
static uint32_t wim_nb_files, wim_proc_files;
|
|
||||||
static BOOL count_files;
|
static BOOL count_files;
|
||||||
static uint64_t LastRefresh;
|
|
||||||
|
|
||||||
static BOOL Get7ZipPath(void)
|
static BOOL Get7ZipPath(void)
|
||||||
{
|
{
|
||||||
|
@ -572,7 +572,6 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
|
||||||
PWIN32_FIND_DATA pFileData;
|
PWIN32_FIND_DATA pFileData;
|
||||||
const char* level = NULL;
|
const char* level = NULL;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
float apply_percent;
|
|
||||||
|
|
||||||
switch (dwMsgId) {
|
switch (dwMsgId) {
|
||||||
case WIM_MSG_PROGRESS:
|
case WIM_MSG_PROGRESS:
|
||||||
|
@ -593,20 +592,13 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
|
||||||
if (count_files) {
|
if (count_files) {
|
||||||
wim_nb_files++;
|
wim_nb_files++;
|
||||||
} else {
|
} else {
|
||||||
|
// 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++;
|
wim_proc_files++;
|
||||||
if (GetTickCount64() > LastRefresh + 100) {
|
else
|
||||||
// At the end of an actual apply, the WIM API re-lists a bunch of directories it
|
wim_extra_files++;
|
||||||
// already processed, so we end up with more entries than counted - ignore those.
|
UpdateProgressWithInfo(OP_FILE_COPY, MSG_267, wim_proc_files, wim_nb_files);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Halt on error
|
// Halt on error
|
||||||
if (IS_ERROR(FormatStatus)) {
|
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
|
// Run a first pass using WIM_FLAG_NO_APPLY to count the files
|
||||||
wim_nb_files = 0;
|
wim_nb_files = 0;
|
||||||
wim_proc_files = 0;
|
wim_proc_files = 0;
|
||||||
LastRefresh = 0;
|
wim_extra_files = 0;
|
||||||
count_files = TRUE;
|
count_files = TRUE;
|
||||||
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) {
|
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) {
|
||||||
uprintf(" Could not count the files to apply: %s", WindowsErrorString());
|
uprintf(" Could not count the files to apply: %s", WindowsErrorString());
|
||||||
goto out;
|
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;
|
count_files = FALSE;
|
||||||
// Actual apply
|
// Actual apply
|
||||||
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_FILEINFO)) {
|
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_FILEINFO)) {
|
||||||
uprintf(" Could not apply image: %s", WindowsErrorString());
|
uprintf(" Could not apply image: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
PrintInfo(0, MSG_267, 99.8f);
|
// Ensure that we'll pick if need to readjust our 20% above from user reports
|
||||||
UpdateProgress(OP_FILE_COPY, 99.8f);
|
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;
|
r = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in a new issue