mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] improve error reporting for download issues
* This is part of #1444
This commit is contained in:
parent
b8b22ee890
commit
87a7228d38
5 changed files with 38 additions and 16 deletions
|
@ -2982,7 +2982,6 @@ DWORD WINAPI FormatThread(void* param)
|
|||
}
|
||||
|
||||
out:
|
||||
zero_drive = FALSE;
|
||||
safe_free(volume_name);
|
||||
safe_free(buffer);
|
||||
safe_closehandle(hSourceImage);
|
||||
|
|
38
src/rufus.c
38
src/rufus.c
|
@ -50,6 +50,13 @@
|
|||
#include "../res/grub/grub_version.h"
|
||||
#include "../res/grub2/grub2_version.h"
|
||||
|
||||
enum bootcheck_return {
|
||||
BOOTCHECK_PROCEED = 0,
|
||||
BOOTCHECK_CANCEL = -1,
|
||||
BOOTCHECK_DOWNLOAD_ERROR = -2,
|
||||
BOOTCHECK_GENERAL_ERROR = -3,
|
||||
};
|
||||
|
||||
static const char* cmdline_hogger = "rufus.com";
|
||||
static const char* ep_reg = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
|
||||
static const char* vs_reg = "Software\\Microsoft\\VisualStudio";
|
||||
|
@ -1185,7 +1192,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
int i, r;
|
||||
FILE *fd;
|
||||
DWORD len;
|
||||
WPARAM ret = -1;
|
||||
WPARAM ret = BOOTCHECK_CANCEL;
|
||||
BOOL in_files_dir = FALSE;
|
||||
const char* grub = "grub";
|
||||
const char* core_img = "core.img";
|
||||
|
@ -1202,7 +1209,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
|
||||
if ((zero_drive) || (boot_type == BT_NON_BOOTABLE)) {
|
||||
// Nothing to check
|
||||
ret = 0;
|
||||
ret = BOOTCHECK_PROCEED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1224,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
}
|
||||
if (IS_DD_BOOTABLE(img_report) && !img_report.is_iso) {
|
||||
// Pure DD images are fine at this stage
|
||||
ret = 0;
|
||||
ret = BOOTCHECK_PROCEED;
|
||||
goto out;
|
||||
}
|
||||
if ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION)) == 1)) {
|
||||
|
@ -1375,6 +1382,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
len = DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE);
|
||||
if (len == 0) {
|
||||
uprintf("Could not download file - cancelling");
|
||||
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||
goto out;
|
||||
}
|
||||
use_own_c32[i] = TRUE;
|
||||
|
@ -1442,6 +1450,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
uprintf("Could not download the file - will try to use embedded %s version instead", img_report.sl_version_str);
|
||||
} else {
|
||||
uprintf("Could not download the file - cancelling");
|
||||
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -1470,10 +1479,12 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[1]);
|
||||
IGNORE_RETVAL(_mkdir(tmp));
|
||||
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, embedded_sl_version_str[1], ldlinux, ldlinux_ext[2]);
|
||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0)
|
||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0) {
|
||||
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (boot_type == BT_MSDOS) {
|
||||
if ((size_check) && (ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)) >= 65536)) {
|
||||
// MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size
|
||||
|
@ -1500,11 +1511,13 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
|||
static_sprintf(tmp, "grub4dos-%s", GRUB4DOS_VERSION);
|
||||
IGNORE_RETVAL(_mkdir(tmp));
|
||||
static_sprintf(tmp, "%s/grub4dos-%s/grldr", FILES_URL, GRUB4DOS_VERSION);
|
||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0)
|
||||
if (DownloadSignedFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog, TRUE) == 0) {
|
||||
ret = BOOTCHECK_DOWNLOAD_ERROR;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uefi_target:
|
||||
if (boot_type == BT_UEFI_NTFS) {
|
||||
|
@ -1514,7 +1527,7 @@ uefi_target:
|
|||
goto out;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
ret = BOOTCHECK_PROCEED;
|
||||
|
||||
out:
|
||||
PostMessage(hMainDialog, UM_FORMAT_START, ret, 0);
|
||||
|
@ -2622,8 +2635,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
break;
|
||||
|
||||
case UM_FORMAT_START:
|
||||
if (wParam != 0)
|
||||
if (wParam != BOOTCHECK_PROCEED)
|
||||
goto aborted_start;
|
||||
// All subsequent aborts below translate to a user cancellation
|
||||
wParam = BOOTCHECK_CANCEL;
|
||||
|
||||
if ((partition_type == PARTITION_STYLE_MBR) && (SelectedDrive.DiskSize > 2 * TB)) {
|
||||
if (MessageBoxExU(hMainDialog, lmprintf(MSG_134, SizeToHumanReadable(SelectedDrive.DiskSize - 2 * TB, FALSE, FALSE)),
|
||||
|
@ -2699,14 +2714,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
if (format_thid != NULL)
|
||||
break;
|
||||
aborted_start:
|
||||
EnableControls(TRUE, FALSE);
|
||||
zero_drive = FALSE;
|
||||
if (queued_hotplug_event)
|
||||
SendMessage(hDlg, UM_MEDIA_CHANGE, 0, 0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
|
||||
if (wParam == BOOTCHECK_CANCEL) {
|
||||
EnableControls(TRUE, FALSE);
|
||||
break;
|
||||
}
|
||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) |
|
||||
((wParam == BOOTCHECK_DOWNLOAD_ERROR) ? APPERR(ERROR_CANT_DOWNLOAD) : ERROR_GEN_FAILURE);
|
||||
// Fall through
|
||||
|
||||
case UM_FORMAT_COMPLETED:
|
||||
zero_drive = FALSE;
|
||||
format_thid = NULL;
|
||||
// Stop the timer
|
||||
KillTimer(hMainDialog, TID_APP_TIMER);
|
||||
|
|
|
@ -663,3 +663,4 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
|
|||
#define ERROR_CANT_ASSIGN_LETTER 0x120B
|
||||
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
||||
#define ERROR_BAD_SIGNATURE 0x120D
|
||||
#define ERROR_CANT_DOWNLOAD 0x120E
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -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.9.1596"
|
||||
CAPTION "Rufus 3.9.1597"
|
||||
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,9,1596,0
|
||||
PRODUCTVERSION 3,9,1596,0
|
||||
FILEVERSION 3,9,1597,0
|
||||
PRODUCTVERSION 3,9,1597,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -413,13 +413,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.9.1596"
|
||||
VALUE "FileVersion", "3.9.1597"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-3.9.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.9.1596"
|
||||
VALUE "ProductVersion", "3.9.1597"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -766,6 +766,8 @@ const char* _StrError(DWORD error_code)
|
|||
return lmprintf(MSG_079);
|
||||
case ERROR_BAD_SIGNATURE:
|
||||
return lmprintf(MSG_172);
|
||||
case ERROR_CANT_DOWNLOAD:
|
||||
return lmprintf(MSG_242);
|
||||
default:
|
||||
SetLastError(error_code);
|
||||
return WindowsErrorString();
|
||||
|
|
Loading…
Reference in a new issue