public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin-apps@cygwin.com
Subject: [PATCH setup 1/2] Improve behavior after download error
Date: Mon, 06 Nov 2017 21:49:00 -0000	[thread overview]
Message-ID: <20171106214907.7120-2-kbrown@cornell.edu> (raw)
In-Reply-To: <20171106214907.7120-1-kbrown@cornell.edu>

If the user answers "Yes" to "Download incomplete.  Try again?",
simply try the download again, as the message suggests, instead of
going back to the site page.  If the user answers no, don't proceed
with the install unless the user confirms that this is what they want.

The rationale for the previous behavior was presumably to let the user
choose a different mirror after a download error.  But this is not
clear from the "Try again?" prompt, and it probably didn't work as
expected if the user did choose a different mirror.  To make this work
right, packagedb would have to have been cleared before going to the
chooser page for the second time.
---
 download.cc | 29 ++++++++++++++++++++---------
 res.rc      |  1 +
 resource.h  |  1 +
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/download.cc b/download.cc
index 80615f3..6ee64c1 100644
--- a/download.cc
+++ b/download.cc
@@ -195,6 +195,11 @@ static int
 do_download_thread (HINSTANCE h, HWND owner)
 {
   int errors = 0;
+  int retries = 5;
+
+  do
+    {
+  errors = 0;
   total_download_bytes = 0;
   total_download_bytes_sofar = 0;
 
@@ -271,22 +276,20 @@ do_download_thread (HINSTANCE h, HWND owner)
 	 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)
+      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);
 	}
       else if (unattended_mode)
-        {
 	  Log (LOG_PLAIN) << "download error in unattended_mode: " << retries
 	    << (retries > 1 ? " retries" : " retry") << " remaining." << endLog;
-	  return IDD_SITE;
-	}
-      else if (yesno (owner, IDS_DOWNLOAD_INCOMPLETE) == IDYES)
-	return IDD_SITE;
+      else if (yesno (owner, IDS_DOWNLOAD_INCOMPLETE) == IDNO)
+	break;
     }
+    }
+  while (errors);
 
   if (source == IDC_SOURCE_DOWNLOAD)
     {
@@ -296,8 +299,16 @@ do_download_thread (HINSTANCE h, HWND owner)
 	Logger ().setExitMsg (IDS_DOWNLOAD_COMPLETE);
       return IDD_DESKTOP;
     }
-  else
-    return IDD_S_INSTALL;
+
+  if (errors)
+    {
+      if (yesno (owner, IDS_CONTINUE_INSTALL) == IDNO)
+	{
+	  Logger ().setExitMsg (IDS_INSTALL_INCOMPLETE);
+	  Logger ().exit (1);
+	}
+    }
+  return IDD_S_INSTALL;
 }
 
 static DWORD WINAPI
diff --git a/res.rc b/res.rc
index 96dcf00..40e464b 100644
--- a/res.rc
+++ b/res.rc
@@ -523,6 +523,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_CONTINUE_INSTALL    "Download incomplete.  Continue with install anyway?"
     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..b6685e5 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_CONTINUE_INSTALL              141
 
 // Dialogs
 
-- 
2.15.0

  parent reply	other threads:[~2017-11-06 21:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 21:49 [PATCH setup 0/2] " Ken Brown
2017-11-06 21:49 ` [PATCH setup 2/2] Whitespace fixes Ken Brown
2017-11-06 21:49 ` Ken Brown [this message]
2017-11-07  4:28 ` [PATCH setup 0/2] Improve behavior after download error Brian Inglis
2017-11-07 18:56   ` Jon Turney
2017-11-08 14:35     ` Ken Brown
2017-11-08 18:52       ` Brian Inglis
2017-11-09 13:21         ` Jon Turney
2017-11-09 16:42           ` Ken Brown
2017-11-10 14:41             ` Ken Brown
2017-11-08 18:46     ` Brian Inglis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171106214907.7120-2-kbrown@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).