From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup] Migrate selected sites from http:// to https://
Date: Tue, 21 Jul 2020 15:15:53 +0100 [thread overview]
Message-ID: <20200721141553.28175-1-jon.turney@dronecode.org.uk> (raw)
If a selected site URL saved from the last run starts with "http://",
and an identical URL except starting with "https://" is in the current
mirror list, migrate it from "http://" to "https://".
---
Notes:
This is useful because it lets us consolidate http:// and https://
entries in the mirror list, without causing setup to warn about http://
sites being dropped from the mirror list.
site.cc | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/site.cc b/site.cc
index b9a5119..2c6421f 100644
--- a/site.cc
+++ b/site.cc
@@ -320,6 +320,44 @@ load_site_list (SiteList& theSites, char *theString)
}
}
+/* Protocol migrations */
+#define HTTP "http://"
+#define HTTP_LEN (strlen(HTTP))
+#define HTTPS "https://"
+
+static void
+migrate_selected_site_list()
+{
+ SiteList result;
+
+ for (SiteList::const_iterator i = site_list.begin();
+ i != site_list.end();
+ ++i)
+ {
+ /* If the saved selected site URL starts with "http://", and the same URL,
+ but starting with "https://" appears in the mirror list, migrate to
+ "https://" */
+ if (strnicmp(i->url.c_str(), HTTP, HTTP_LEN) == 0)
+ {
+ std::string migrated_site = "https://";
+ migrated_site.append(&(i->url.c_str()[HTTP_LEN]));
+
+ site_list_type migrate(migrated_site, "", "", "", false);
+ SiteList::iterator j = find (all_site_list.begin(),
+ all_site_list.end(), migrate);
+ if (j != all_site_list.end())
+ {
+ Log (LOG_PLAIN) << "Migrated " << i->url << " to " << migrated_site << endLog;
+ result.push_back(migrate);
+ continue;
+ }
+ }
+ result.push_back(*i);
+ }
+
+ site_list = result;
+}
+
static int
get_site_list (HINSTANCE h, HWND owner)
{
@@ -370,10 +408,12 @@ get_site_list (HINSTANCE h, HWND owner)
load_site_list (all_site_list, theMirrorString);
load_site_list (cached_site_list, theCachedString);
-
+
delete[] theMirrorString;
delete[] theCachedString;
+ migrate_selected_site_list();
+
return 0;
}
--
2.27.0
reply other threads:[~2020-07-21 14:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200721141553.28175-1-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--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).