[PATCH] setup: mirror list caching

Igor Pechtchanski pechtcha@cs.nyu.edu
Thu Sep 29 16:31:00 GMT 2005


Hi,

The attached (Q&D) patch implements rudimentary mirror list caching.  The
mirror list will be fully downloaded from sources.redhat.com every time if
possible, but if the site is down, a local copy (from last download) will
be used.  There is no true "caching" (with timestamps, etc), but this
could be refined later.

I've tested this on two WinXP machines -- seems to work.  We might want to
apply this soon and release a setup snapshot before this weekend, because
of <http://cygwin.com/ml/cygwin/2005-09/msg00993.html>.

As usual, the ChangeLog is below.
	Igor
==============================================================================
ChangeLog:
2005-09-29  Igor Pechtchanski  <pechtcha@cs.nyu.edu>

	* site.cc (get_site_list): Store mirror list locally.
	Use local copy if unable to download.

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA
-------------- next part --------------
--- CVS/Base/site.cc	2005-05-21 19:04:03.000000000 -0400
+++ site.cc	2005-09-29 11:58:05.307665600 -0400
@@ -201,9 +201,29 @@ get_site_list (HINSTANCE h, HWND owner)
   char *bol, *eol, *nl, *theString;
   {
     String mirrors = get_url_to_string (mirror_url, owner);
-    if (!mirrors.size())
-      return 1;
-
+    if (mirrors.size())
+      {
+	io_stream *f = UserSettings::Instance().settingFileForSave("mirrors-lst");
+	if (f)
+	  {
+	    f->write(mirrors.c_str(), mirrors.size() + 1);
+	    delete f;
+	  }
+      }
+    else
+      {
+	io_stream *f = UserSettings::Instance().settingFileForLoad("mirrors-lst");
+	int len;
+	if (!f)
+	  return 1;
+	while (len = f->read (mirror_url, 999))
+	  {
+	    mirror_url[len] = '\0';
+	    mirrors += mirror_url;
+	  }
+	delete f;
+	log (LOG_BABBLE) << "Using cached mirror list" << endLog;
+      }
     theString = new_cstr_char_array (mirrors);
     nl = theString;
   }


More information about the Cygwin-apps mailing list