This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/5] Report overall progress while md5summing packages


md5sum checking all packages can take minutes with a large number of
packages to install, so report not only progress on the checking for
each individual package, but how far we are through the operation on
all packages

2011-04-24  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* install.cc (do_install_thread): Report overall progress while
	md5summing packages.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
 install.cc |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/install.cc b/install.cc
index a1337da..68bf116 100644
--- a/install.cc
+++ b/install.cc
@@ -628,6 +628,29 @@ do_install_thread (HINSTANCE h, HWND owner)
   vector <packagemeta *> install_q, uninstall_q, sourceinstall_q;
 
   packagedb db;
+
+  /* Calculate the amount of data to md5sum */
+  Progress.SetText1("Calculating...");
+  int md5sum_total_bytes = 0;
+  for (packagedb::packagecollection::iterator i = db.packages.begin ();
+       i != db.packages.end (); ++i)
+  {
+    packagemeta & pkg = *(i->second);
+
+    if (pkg.desired.picked())
+    {
+      md5sum_total_bytes += pkg.desired.source()->size;
+    }
+
+    if (pkg.desired.sourcePackage ().picked())
+    {
+      md5sum_total_bytes += pkg.desired.sourcePackage ().source()->size;
+    }
+  }
+
+  /* md5sum the packages, build lists of packages to install and uninstall
+     and calculate the total amount of data to install */
+  int md5sum_total_bytes_sofar = 0;
   for (packagedb::packagecollection::iterator i = db.packages.begin ();
        i != db.packages.end (); ++i)
   {
@@ -646,6 +669,7 @@ do_install_thread (HINSTANCE h, HWND owner)
       }
       if (pkg.desired.picked())
       {
+        md5sum_total_bytes_sofar += pkg.desired.source()->size;
         total_bytes += pkg.desired.source()->size;
         install_q.push_back (&pkg);
       }
@@ -664,6 +688,7 @@ do_install_thread (HINSTANCE h, HWND owner)
       }
       if (pkg.desired.sourcePackage().picked())
       {
+        md5sum_total_bytes_sofar += pkg.desired.sourcePackage ().source()->size;
         total_bytes += pkg.desired.sourcePackage ().source()->size;
         sourceinstall_q.push_back (&pkg);
       }
@@ -674,6 +699,8 @@ do_install_thread (HINSTANCE h, HWND owner)
     {
       uninstall_q.push_back (&pkg);
     }
+
+    Progress.SetBar2 (md5sum_total_bytes_sofar, md5sum_total_bytes);
   }
 
   /* start with uninstalls - remove files that new packages may replace */
-- 
1.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]