From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24652 invoked by alias); 13 Nov 2017 18:49:44 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 24488 invoked by uid 9996); 13 Nov 2017 18:49:43 -0000 Date: Mon, 13 Nov 2017 18:49:00 -0000 Message-ID: <20171113184943.24422.qmail@sourceware.org> From: kbrown@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.882-4-gdcbcbef X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: a70f0d5617189495dc1515ecb68dbd7ef5be111c X-Git-Newrev: dcbcbef35bb4a61d4d05897ee66cc5ec314a854b X-SW-Source: 2017-q4/txt/msg00030.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=dcbcbef35bb4a61d4d05897ee66cc5ec314a854b commit dcbcbef35bb4a61d4d05897ee66cc5ec314a854b Author: Ken Brown Date: Mon Nov 13 12:27:58 2017 -0500 Query user after download error in interactive mode Instead of just giving the user a "Try again?" Yes/No choice that goes to IDD_SITE on Yes, create a dialog IDD_DOWNLOAD_ERROR with the following choices: 'Retry' (retry the download), 'Back' (return to IDD_CHOOSE), 'Continue' (ignore the errors), or 'Cancel' (exit). The dialog lists the packages that had download errors so that the user can make an informed choice. Users who liked the old behavior (IDD_SITE) can select Back twice. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=94d2919d7e54dc7a84da3106fb70dd1674afc155 commit 94d2919d7e54dc7a84da3106fb70dd1674afc155 Author: Ken Brown Date: Mon Nov 13 12:23:35 2017 -0500 Remove "Try again?" from exit message https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=8311c03f3126a367d41723968fbaa0da2ca1483e commit 8311c03f3126a367d41723968fbaa0da2ca1483e Author: Ken Brown Date: Fri Nov 10 09:43:36 2017 -0500 Fix off-by-one error in download retry report 'retries' was decremented after it was tested but before it was reported in the log, so the reported number was always 1 too low. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=0a9f27ceb04d564b42c8e28633ce827e0e6bb0b4 commit 0a9f27ceb04d564b42c8e28633ce827e0e6bb0b4 Author: Ken Brown Date: Fri Nov 10 09:43:35 2017 -0500 Just retry download after error in unattended mode After a download error, setup was going back to IDD_SITE. This is pointless in unattended mode, since no changes in the mirrors or packages can be made. Change misleading comment about retries in unattended mode; the Yes/No dialog is not used in that case. Diff: --- download.cc | 91 +++++++++++++++++++++++++++++++++++++++++++++++++--------- res.rc | 23 +++++++++++++++ resource.h | 3 ++ 3 files changed, 103 insertions(+), 14 deletions(-) diff --git a/download.cc b/download.cc index 80615f3..5a7a1c2 100644 --- a/download.cc +++ b/download.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include "resource.h" #include "msg.h" @@ -187,16 +188,65 @@ download_one (packagesource & pkgsource, HWND owner) } if (success) return 0; - /* FIXME: Do we want to note this? if so how? */ return 1; } +static std::vector download_failures; +static std::string download_warn_pkgs; + +static INT_PTR CALLBACK +download_error_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + eset (h, IDC_DOWNLOAD_EDIT, download_warn_pkgs); + SetFocus (GetDlgItem(h, IDRETRY)); + return FALSE; + + case WM_COMMAND: + switch (LOWORD (wParam)) + { + case IDRETRY: + case IDC_BACK: + case IDIGNORE: + case IDABORT: + EndDialog (h, LOWORD (wParam)); + default: + // Not reached. + return 0; + } + + default: + // Not handled. + return FALSE; + } + return TRUE; +} + +static int +query_download_errors (HINSTANCE h, HWND owner) +{ + download_warn_pkgs = ""; + Log (LOG_PLAIN) << "The following package(s) had download errors:" << endLog; + for (std::vector ::const_iterator i = download_failures.begin (); i != download_failures.end (); i++) + { + packageversion pv = *i; + std::string pvs = pv.Name () + "-" + pv.Canonical_version (); + Log (LOG_PLAIN) << " " << pvs << endLog; + download_warn_pkgs += pvs + "\r\n"; + } + return DialogBox (h, MAKEINTRESOURCE (IDD_DOWNLOAD_ERROR), owner, + download_error_proc); +} + static int do_download_thread (HINSTANCE h, HWND owner) { int errors = 0; total_download_bytes = 0; total_download_bytes_sofar = 0; + download_failures.clear (); Progress.SetText1 ("Checking for packages to download..."); Progress.SetText2 (""); @@ -257,6 +307,8 @@ do_download_thread (HINSTANCE h, HWND owner) e += download_one (*sourceversion.source (), owner); } errors += e; + if (e) + download_failures.push_back (version); #if 0 if (e) pkg->action = ACTION_ERROR; @@ -266,32 +318,43 @@ do_download_thread (HINSTANCE h, HWND owner) if (errors) { - /* In unattended mode, all dialog boxes automatically get - answered with a Yes/OK/other positive response. This - means that if there's a download problem, setup will - potentially retry forever if we don't take care to give - up at some finite point. */ - static int retries = 4; - if (unattended_mode && retries-- <= 0) + // In unattended mode we retry the download, but not forever. + static int retries = 5; + int rc; + if (unattended_mode && --retries <= 0) { Log (LOG_PLAIN) << "download error in unattended_mode: out of retries" << endLog; - Logger ().setExitMsg (IDS_INSTALL_INCOMPLETE); - Logger ().exit (1); + rc = IDABORT; } else if (unattended_mode) { Log (LOG_PLAIN) << "download error in unattended_mode: " << retries << (retries > 1 ? " retries" : " retry") << " remaining." << endLog; - return IDD_SITE; + rc = IDRETRY; + } + else + rc = query_download_errors (h, owner); + switch (rc) + { + case IDRETRY: + Progress.SetActivateTask (WM_APP_START_DOWNLOAD); + return IDD_INSTATUS; + case IDC_BACK: + return IDD_CHOOSE; + case IDABORT: + Logger ().setExitMsg (IDS_DOWNLOAD_INCOMPLETE_EXIT); + Logger ().exit (1); + case IDIGNORE: + break; + default: + break; } - else if (yesno (owner, IDS_DOWNLOAD_INCOMPLETE) == IDYES) - return IDD_SITE; } if (source == IDC_SOURCE_DOWNLOAD) { if (errors) - Logger ().setExitMsg (IDS_DOWNLOAD_INCOMPLETE); + Logger ().setExitMsg (IDS_DOWNLOAD_INCOMPLETE_EXIT); else if (!unattended_mode) Logger ().setExitMsg (IDS_DOWNLOAD_COMPLETE); return IDD_DESKTOP; diff --git a/res.rc b/res.rc index 96dcf00..80d1bf1 100644 --- a/res.rc +++ b/res.rc @@ -413,6 +413,28 @@ BEGIN END +IDD_DOWNLOAD_ERROR DIALOG DISCARDABLE 0, 0, SETUP_STANDARD_DIALOG_DIMS +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION +CAPTION "Download Incomplete" +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDI_WARNING,IDC_HEADICON,10,10 + LTEXT "The following package(s) had download errors:", + IDC_STATIC,7,8,320,16 + EDITTEXT IDC_DOWNLOAD_EDIT,7,24,320,88,WS_VSCROLL | + ES_LEFT | ES_MULTILINE | ES_READONLY | + ES_AUTOVSCROLL + LTEXT "Select 'Retry' to retry the download, " + "'Back' to return to the package selection page, " + "'Continue' to go on anyway (NOT RECOMMENDED), or " + "'Cancel' to exit.", + IDC_STATIC,7,120,320,24 + DEFPUSHBUTTON "&Retry",IDRETRY,45,150,50,15 + PUSHBUTTON "&Back",IDC_BACK,110,150,50,15 + PUSHBUTTON "&Continue",IDIGNORE,175,150,50,15 + PUSHBUTTON "Cancel",IDABORT,240,150,50,15 +END + IDD_POSTINSTALL DIALOG DISCARDABLE 0, 0, SETUP_STANDARD_DIALOG_W, 142 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU @@ -523,6 +545,7 @@ BEGIN IDS_ERR_CHDIR "Could not change dir to %s: %s [%.8x]" IDS_OLD_SETUP_VERSION "This setup is version %s, but setup.ini claims version %s is available.\nYou might want to upgrade to get the latest features and bug fixes." IDS_DOWNLOAD_INCOMPLETE "Download Incomplete. Try again?" + IDS_DOWNLOAD_INCOMPLETE_EXIT "Download incomplete. Check %s for details" IDS_INSTALL_ERROR "Installation error (%s), Continue with other packages?" IDS_INSTALL_INCOMPLETE "Installation incomplete. Check %s for details" IDS_CORRUPT_PACKAGE "Package file %s has a corrupt local copy, please remove and retry." diff --git a/resource.h b/resource.h index a2add84..0cc70ca 100644 --- a/resource.h +++ b/resource.h @@ -39,6 +39,7 @@ #define IDS_NO_LOCALDIR 138 #define IDS_ELEVATED 139 #define IDS_INSTALLEDB_VERSION 140 +#define IDS_DOWNLOAD_INCOMPLETE_EXIT 141 // Dialogs @@ -66,6 +67,7 @@ #define IDD_DROPPED 221 #define IDD_POSTINSTALL 222 #define IDD_FILE_INUSE 223 +#define IDD_DOWNLOAD_ERROR 224 // Bitmaps @@ -175,3 +177,4 @@ #define IDC_FILE_INUSE_MSG 591 #define IDC_FILE_INUSE_HELP 592 #define IDC_NET_DIRECT_LEGACY 593 +#define IDC_DOWNLOAD_EDIT 594