[PATCH setup] Migrate selected sites from http:// to https://
Jon Turney
jon.turney@dronecode.org.uk
Tue Jul 21 14:15:53 GMT 2020
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
More information about the Cygwin-apps
mailing list